Skip to content

Commit

Permalink
[BUGFIX release] Don’t leak container while injection deprecated cont…
Browse files Browse the repository at this point in the history
…ainer

(cherry picked from commit c68ea41)
  • Loading branch information
stefanpenner authored and rwjblue committed Apr 27, 2017
1 parent b100b70 commit 5bf3594
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions packages/container/lib/container.js
Expand Up @@ -564,31 +564,28 @@ function factoryInjectionsFor(container, fullName) {
return factoryInjections;
}

const INJECTED_DEPRECATED_CONTAINER_DESC = {
configurable: true,
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];
},

set(value) {
deprecate(`Providing the \`container\` property to ${this} is deprecated. Please use \`Ember.setOwner\` or \`owner.ownerInjection()\` instead to provide an owner to the instance being created.`, false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' });

this[CONTAINER_OVERRIDE] = value;

return value;
}
};

// TODO - remove when Ember reaches v3.0.0
function injectDeprecatedContainer(object, container) {
if ('container' in object) { return; }
Object.defineProperty(object, 'container', {
configurable: true,
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] || container;
},

set(value) {
deprecate(
`Providing the \`container\` property to ${this} is deprecated. Please use \`Ember.setOwner\` or \`owner.ownerInjection()\` instead to provide an owner to the instance being created.`,
false,
{ id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }
);

this[CONTAINER_OVERRIDE] = value;

return value;
}
});
Object.defineProperty(object, 'container', INJECTED_DEPRECATED_CONTAINER_DESC);
object[CONTAINER_OVERRIDE] = container;
}

function eachDestroyable(container, callback) {
Expand Down

0 comments on commit 5bf3594

Please sign in to comment.