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
  • Loading branch information
chriskrycho committed Mar 16, 2022
1 parent d8f8266 commit d79edb3
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 extends FactoryClass | object = FactoryClass> {
);
}

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 d79edb3

Please sign in to comment.