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.
(cherry picked from commit cfa7c65)
  • Loading branch information
stefanpenner authored and chancancode committed Mar 14, 2017
1 parent 756c845 commit 25cf68a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/container/lib/container.js
Expand Up @@ -533,7 +533,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 @@ -557,6 +557,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 @@ -693,8 +694,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 25cf68a

Please sign in to comment.