Skip to content

Commit

Permalink
Merge pull request #15163 from rwjblue/avoid-leaking-container
Browse files Browse the repository at this point in the history
[BUGFIX beta] Avoid storing container on the prototype.
  • Loading branch information
rwjblue authored Apr 24, 2017
2 parents f44f1d5 + 4cd5b80 commit b80407b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
dictionary,
symbol,
setOwner,
getOwner,
OWNER,
assign,
NAME_KEY,
Expand Down Expand Up @@ -521,7 +522,7 @@ const INJECTED_DEPRECATED_CONTAINER_DESC = {
enumerable: false,
get() {
deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' });
return this[CONTAINER_OVERRIDE];
return this[CONTAINER_OVERRIDE] || getOwner(this).__container__;
},

set(value) {
Expand All @@ -537,7 +538,6 @@ const INJECTED_DEPRECATED_CONTAINER_DESC = {
function injectDeprecatedContainer(object, container) {
if ('container' in object) { return; }
Object.defineProperty(object, 'container', INJECTED_DEPRECATED_CONTAINER_DESC);
object[CONTAINER_OVERRIDE] = container;
}

function destroyDestroyables(container) {
Expand Down
4 changes: 2 additions & 2 deletions packages/container/tests/container_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@ QUnit.test('An object with its owner pre-set should be returned from ownerInject
});

QUnit.test('A deprecated `container` property is appended to every object instantiated from an extendable factory', function() {
let owner = { };
let registry = new Registry();
let container = registry.container();
let container = owner.__container__ = registry.container({ owner });
let PostController = factory();
registry.register('controller:post', PostController);
let postController = container.lookup('controller:post');
Expand Down Expand Up @@ -741,4 +742,3 @@ QUnit.test('#factoryFor options passed to create clobber injections', (assert) =

assert.equal(instrance.ajax, 'fetch');
});

0 comments on commit b80407b

Please sign in to comment.