Skip to content

Commit

Permalink
Merge pull request #12441 from dgeb/remove-di-reform-flag
Browse files Browse the repository at this point in the history
Remove `ember-registry-container-reform` feature flag.
  • Loading branch information
rwjblue committed Oct 5, 2015
2 parents d34c9ea + a8107d1 commit 23258c1
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 230 deletions.
12 changes: 0 additions & 12 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,6 @@ for a detailed explanation.
Implements RFC https://github.com/emberjs/rfcs/pull/65, adding support for
custom deprecation and warning handlers.

* `ember-registry-container-reform`

Implements RFC https://github.com/emberjs/rfcs/pull/46, fully encapsulating
and privatizing the `Container` and `Registry` classes by exposing a select
subset of public methods on `Application` and `ApplicationInstance`.

`Application` initializers now receive a single argument to `initialize`:
`application`.

Likewise, `ApplicationInstance` initializers still receive a single argument
to initialize: `applicationInstance`.

* `ember-routing-routable-components`

Implements RFC https://github.com/emberjs/rfcs/pull/38, adding support for
Expand Down
1 change: 0 additions & 1 deletion features.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"ember-routing-route-configured-query-params": null,
"ember-libraries-isregistered": null,
"ember-debug-handlers": true,
"ember-registry-container-reform": true,
"ember-routing-routable-components": null,
"ember-metal-ember-assign": null,
"ember-contextual-components": null
Expand Down
13 changes: 0 additions & 13 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Ember from 'ember-metal/core';
import { assert } from 'ember-metal/debug';
import dictionary from 'ember-metal/dictionary';
import isEnabled from 'ember-metal/features';

/**
A container used to instantiate and cache objects.
Expand Down Expand Up @@ -351,16 +350,4 @@ function resetMember(container, fullName) {
}
}

// Once registry / container reform is enabled, we no longer need to expose
// Container#_registry, since Container itself will be fully private.
if (!isEnabled('ember-registry-container-reform')) {
Object.defineProperty(Container.prototype, '_registry', {
configurable: true,
enumerable: false,
get() {
return this.registry;
}
});
}

export default Container;
11 changes: 0 additions & 11 deletions packages/container/tests/container_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Ember from 'ember-metal/core';
import Registry from 'container/registry';
import { factory } from 'container/tests/container_helper';
import isEnabled from 'ember-metal/features';

var originalModelInjections;

Expand Down Expand Up @@ -536,13 +535,3 @@ QUnit.test('Lazy injection validations are cached', function() {
container.lookup('apple:main');
container.lookup('apple:main');
});

if (!isEnabled('ember-registry-container-reform')) {
QUnit.test('Container#_registry provides an alias to Container#registry while Container is pseudo-public', function() {
var registry = new Registry();
var container = registry.container();

strictEqual(container.registry, registry, '#registry points to the parent registry');
strictEqual(container._registry, registry, '#_registry is an alias to #registry');
});
}
61 changes: 27 additions & 34 deletions packages/ember-application/lib/system/application-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ let ApplicationInstance = EmberObject.extend(RegistryProxy, ContainerProxy, {
// in tests, or rendered to a string in the case of FastBoot.
this.register('-application-instance:main', this, { instantiate: false });

if (!isEnabled('ember-registry-container-reform')) {
this.container = this.__container__;
this.registry = this.__registry__;
}

this._booted = false;
},

Expand Down Expand Up @@ -543,35 +538,33 @@ function isResolverModuleBased(applicationInstance) {
return !!applicationInstance.application.__registry__.resolver.moduleBasedResolver;
}

if (isEnabled('ember-registry-container-reform')) {
Object.defineProperty(ApplicationInstance.prototype, 'container', {
configurable: true,
enumerable: false,
get() {
var instance = this;
return {
lookup() {
deprecate(
'Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead.',
false, {
id: 'ember-application.app-instance-container',
until: '3.0.0',
url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container'
}
);
return instance.lookup(...arguments);
}
};
}
});
Object.defineProperty(ApplicationInstance.prototype, 'container', {
configurable: true,
enumerable: false,
get() {
var instance = this;
return {
lookup() {
deprecate(
'Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead.',
false, {
id: 'ember-application.app-instance-container',
until: '3.0.0',
url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container'
}
);
return instance.lookup(...arguments);
}
};
}
});

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

export default ApplicationInstance;
33 changes: 15 additions & 18 deletions packages/ember-application/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,14 @@ var Application = Namespace.extend(RegistryProxy, {
this._runInitializer('initializers', function(name, initializer) {
assert('No application initializer named \'' + name + '\'', !!initializer);
if (initializer.initialize.length === 2) {
if (isEnabled('ember-registry-container-reform')) {
deprecate('The `initialize` method for Application initializer \'' + name + '\' should take only one argument - `App`, an instance of an `Application`.',
false,
{
id: 'ember-application.app-initializer-initialize-arguments',
until: '3.0.0',
url: 'http://emberjs.com/deprecations/v2.x/#toc_initializer-arity'
});
}
deprecate('The `initialize` method for Application initializer \'' + name + '\' should take only one argument - `App`, an instance of an `Application`.',
false,
{
id: 'ember-application.app-initializer-initialize-arguments',
until: '3.0.0',
url: 'http://emberjs.com/deprecations/v2.x/#toc_initializer-arity'
});

initializer.initialize(App.__registry__, App);
} else {
initializer.initialize(App);
Expand Down Expand Up @@ -901,15 +900,13 @@ var Application = Namespace.extend(RegistryProxy, {
}
});

if (isEnabled('ember-registry-container-reform')) {
Object.defineProperty(Application.prototype, 'registry', {
configurable: true,
enumerable: false,
get() {
return buildFakeRegistryWithDeprecations(this, 'Application');
}
});
}
Object.defineProperty(Application.prototype, 'registry', {
configurable: true,
enumerable: false,
get() {
return buildFakeRegistryWithDeprecations(this, 'Application');
}
});

Application.reopenClass({
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Application from 'ember-application/system/application';
import ApplicationInstance from 'ember-application/system/application-instance';
import run from 'ember-metal/run_loop';
import jQuery from 'ember-views/system/jquery';
import isEnabled from 'ember-metal/features';

let app, appInstance;

Expand Down Expand Up @@ -37,6 +36,8 @@ QUnit.test('an application instance can be created based upon an application', f
});

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

run(function() {
appInstance = ApplicationInstance.create({ application: app });
});
Expand All @@ -45,35 +46,26 @@ QUnit.test('properties (and aliases) are correctly assigned for accessing the co
ok(appInstance.__container__, '#__container__ is accessible');
ok(appInstance.__registry__, '#__registry__ is accessible');

if (isEnabled('ember-registry-container-reform')) {
expect(9);

ok(typeof appInstance.container.lookup === 'function', '#container.lookup is available as a function');

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

expectDeprecation(function() {
appInstance.container.lookup();
}, /Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead./);
// stub with a no-op to keep deprecation test simple
appInstance.__container__.lookup = function() {
ok(true, '#loookup alias is called correctly');
};

expectDeprecation(function() {
appInstance.container.lookup();
}, /Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead./);

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(function() {
appInstance.registry.register();
}, /Using `ApplicationInstance.registry.register` is deprecated. Please use `ApplicationInstance.register` instead./);
} else {
expect(5);
ok(typeof appInstance.registry.register === 'function', '#registry.register is available as a function');
appInstance.__registry__.register = function() {
ok(true, '#register alias is called correctly');
};

strictEqual(appInstance.container, appInstance.__container__, '#container alias should be assigned');
strictEqual(appInstance.registry, appInstance.__registry__, '#registry alias should be assigned');
}
expectDeprecation(function() {
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) {
Expand Down
23 changes: 10 additions & 13 deletions packages/ember-application/tests/system/application_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import EmberRoute from 'ember-routing/system/route';
import jQuery from 'ember-views/system/jquery';
import compile from 'ember-template-compiler/system/compile';
import { _loaded } from 'ember-runtime/system/lazy_load';
import isEnabled from 'ember-metal/features';
import { getDebugFunction, setDebugFunction } from 'ember-metal/debug';

var trim = jQuery.trim;
Expand Down Expand Up @@ -100,21 +99,19 @@ QUnit.test('acts like a namespace', function() {
equal(app.Foo.toString(), 'TestApp.Foo', 'Classes pick up their parent namespace');
});

if (isEnabled('ember-registry-container-reform')) {
QUnit.test('includes deprecated access to `application.registry`', function() {
expect(3);
QUnit.test('includes deprecated access to `application.registry`', function() {
expect(3);

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

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

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

QUnit.module('Ember.Application initialization', {
teardown() {
Expand Down
Loading

0 comments on commit 23258c1

Please sign in to comment.