Skip to content

Commit

Permalink
Correctly associate props with factory and owner in FactoryManager
Browse files Browse the repository at this point in the history
Previously, we stomped the `props` binding with an `Object.assign()`,
which meant that the original empty props object would get GC'd after
the end of the method and the item passed into the class created at the
end of the `FactoryManager.create` call would be a *different* object,
which does *not* have the factory or owner associations.

Fixes #20023

(cherry picked from commit d79edb3)
  • Loading branch information
chriskrycho authored and kategengler committed Mar 21, 2022
1 parent f4b50b5 commit e3a9633
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/@ember/-internals/container/lib/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,10 @@ export class FactoryManager<T, C> {
);
}

let props = {};
let props = options ? { ...options } : {};
setOwner(props, container.owner!);
setFactoryFor(props, this);

if (options !== undefined) {
props = Object.assign({}, props, options);
}

if (DEBUG) {
let lazyInjections;
let validationCache = this.container.validationCache;
Expand Down

0 comments on commit e3a9633

Please sign in to comment.