Skip to content

Commit

Permalink
Merge pull request #15142 from emberjs/dont-leak-container
Browse files Browse the repository at this point in the history
[BUGFIX release] Don’t leak container while injection deprecated cont…
  • Loading branch information
stefanpenner authored Apr 16, 2017
2 parents cb2e278 + e951128 commit 32da960
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,41 +45,30 @@ export default function Container(registry, options) {
}

Container.prototype = {
/**
@private
@property owner
@type Object
*/
owner: null,

/**
@private
@property registry
@type Registry
@since 1.11.0
*/
registry: null,

/**
@private
@property cache
@type InheritingDict
*/
cache: null,

/**
@private
@property factoryCache
@type InheritingDict
*/
factoryCache: null,

/**
@private
@property validationCache
@type InheritingDict
*/
validationCache: null,

/**
Given a fullName return a corresponding instance.
Expand Down Expand Up @@ -527,25 +516,28 @@ function factoryInjectionsFor(container, fullName) {
return factoryInjections;
}

// 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;
},
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' });
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;
this[CONTAINER_OVERRIDE] = value;

return value;
}
});
return value;
}
};

// TODO - remove when Ember reaches v3.0.0
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

0 comments on commit 32da960

Please sign in to comment.