Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLEANUP] Remove deprecated {Application,Engine,ApplicationInstance}.registry #15912

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions packages/ember-application/lib/system/application-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

import { assign } from 'ember-utils';
import { get, set, run, computed } from 'ember-metal';
import {
buildFakeRegistryWithDeprecations,
RSVP
} from 'ember-runtime';
import { RSVP } from 'ember-runtime';
import { environment } from 'ember-environment';
import { jQuery } from 'ember-views';
import EngineInstance from './engine-instance';
Expand Down Expand Up @@ -487,12 +484,4 @@ BootOptions.prototype.toEnvironment = function() {
return env;
};

Object.defineProperty(ApplicationInstance.prototype, 'registry', {
configurable: true,
enumerable: false,
get() {
return buildFakeRegistryWithDeprecations(this, 'ApplicationInstance');
}
});

export default ApplicationInstance;
9 changes: 0 additions & 9 deletions packages/ember-application/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
setNamespaceSearchDisabled,
runLoadHooks,
_loaded,
buildFakeRegistryWithDeprecations,
RSVP
} from 'ember-runtime';
import { EventDispatcher, jQuery } from 'ember-views';
Expand Down Expand Up @@ -978,14 +977,6 @@ const Application = Engine.extend({
}
});

Object.defineProperty(Application.prototype, 'registry', {
configurable: true,
enumerable: false,
get() {
return buildFakeRegistryWithDeprecations(this, 'Application');
}
});

Application.reopenClass({
/**
This creates a registry with the default Ember naming conventions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,6 @@ QUnit.test('an application instance can be created based upon an application', f
equal(appInstance.application, application, 'application should be set to parent');
});

QUnit.test('properties (and aliases) are correctly assigned for accessing the container and registry', function() {
expect(6);

appInstance = run(() => ApplicationInstance.create({ application }));

ok(appInstance, 'instance should be created');
ok(appInstance.__container__, '#__container__ is accessible');
ok(appInstance.__registry__, '#__registry__ is accessible');

// stub with a no-op to keep deprecation test simple
appInstance.__container__.lookup = function() {
ok(true, '#loookup alias is called correctly');
};

ok(typeof appInstance.registry.register === 'function', '#registry.register is available as a function');
appInstance.__registry__.register = function() {
ok(true, '#register alias is called correctly');
};

expectDeprecation(() => {
appInstance.registry.register();
}, /Using `ApplicationInstance.registry.register` is deprecated. Please use `ApplicationInstance.register` instead./);
});

QUnit.test('customEvents added to the application before setupEventDispatcher', function(assert) {
assert.expect(1);

Expand Down
14 changes: 0 additions & 14 deletions packages/ember-application/tests/system/application_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,6 @@ moduleFor('Ember.Application, autobooting multiple apps', class extends Applicat

moduleFor('Ember.Application', class extends ApplicationTestCase {

['@test includes deprecated access to `application.registry`'](assert) {
assert.expect(3);

assert.ok(typeof this.application.registry.register === 'function', '#registry.register is available as a function');

this.application.__registry__.register = function() {
assert.ok(true, '#register alias is called correctly');
};

expectDeprecation(() => {
this.application.registry.register();
}, /Using `Application.registry.register` is deprecated. Please use `Application.register` instead./);
}

[`@test builds a registry`](assert) {
let {application} = this;
assert.strictEqual(application.resolveRegistration('application:main'), application, `application:main is registered`);
Expand Down
1 change: 0 additions & 1 deletion packages/ember-runtime/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export { default as Object, FrameworkObject } from './system/object';
export { default as String } from './system/string';
export {
default as RegistryProxyMixin,
buildFakeRegistryWithDeprecations
} from './mixins/registry_proxy';
export {
default as ContainerProxyMixin
Expand Down
38 changes: 0 additions & 38 deletions packages/ember-runtime/lib/mixins/registry_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import {
Mixin
} from 'ember-metal';
import { deprecate } from 'ember-debug';

/**
RegistryProxyMixin is used to provide public access to specific
Expand Down Expand Up @@ -243,40 +242,3 @@ function registryAlias(name) {
return this.__registry__[name](...arguments);
};
}

export function buildFakeRegistryWithDeprecations(instance, typeForMessage) {
let fakeRegistry = {};
let registryProps = {
resolve: 'resolveRegistration',
register: 'register',
unregister: 'unregister',
has: 'hasRegistration',
option: 'registerOption',
options: 'registerOptions',
getOptions: 'registeredOptions',
optionsForType: 'registerOptionsForType',
getOptionsForType: 'registeredOptionsForType',
injection: 'inject'
};

for (let deprecatedProperty in registryProps) {
fakeRegistry[deprecatedProperty] = buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, registryProps[deprecatedProperty]);
}

return fakeRegistry;
}

function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) {
return function() {
deprecate(
`Using \`${typeForMessage}.registry.${deprecatedProperty}\` is deprecated. Please use \`${typeForMessage}.${nonDeprecatedProperty}\` instead.`,
false,
{
id: 'ember-application.app-instance-registry',
until: '3.0.0',
url: 'https://emberjs.com/deprecations/v2.x/#toc_ember-application-registry-ember-applicationinstance-registry'
}
);
return instance[nonDeprecatedProperty](...arguments);
};
}