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

[BUGFIX release] Don’t leak container while injection deprecated cont… #15142

Merged
merged 2 commits into from
Apr 16, 2017
Merged
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
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