Skip to content

Commit

Permalink
Merge pull request #15008 from emberjs/deprecated-container-perf
Browse files Browse the repository at this point in the history
[BUGFIX beta] only defProp the deprecated container once per prototype
  • Loading branch information
stefanpenner authored Mar 14, 2017
2 parents dfbd82b + cfa7c65 commit 5a36a7d
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 5a36a7d

Please sign in to comment.