Skip to content

Commit

Permalink
[BUGFIX beta] only defProp the deprecated container once per prototype
Browse files Browse the repository at this point in the history
Currently we defProp once pre FactoryManager.prototype.create.
  • Loading branch information
stefanpenner committed Mar 14, 2017
1 parent 2b46034 commit cfa7c65
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ function instantiate(factory, props, container, fullName) {
obj = factory.create(assign({}, injections, props));

// TODO - remove when Ember reaches v3.0.0
if (!Object.isFrozen(obj) && 'container' in obj) {
if (!Object.isFrozen(obj)) {
injectDeprecatedContainer(obj, container);
}
}
Expand All @@ -559,6 +559,7 @@ function factoryInjectionsFor(container, fullName) {

// 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,
Expand Down Expand Up @@ -695,8 +696,9 @@ class FactoryManager {
` an invalid module export.`);
}

if (this.class.prototype) {
injectDeprecatedContainer(this.class.prototype, this.container);
let prototype = this.class.prototype;
if (prototype) {
injectDeprecatedContainer(prototype, this.container);
}

return this.class.create(props);
Expand Down

0 comments on commit cfa7c65

Please sign in to comment.