Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Prevent cycle dependency with owner association. #18270

Merged
merged 1 commit into from
Aug 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/@ember/-internals/runtime/lib/system/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Observable from '../mixins/observable';
import { assert } from '@ember/debug';
import { DEBUG } from '@glimmer/env';

let OVERRIDE_OWNER = symbol('OVERRIDE_OWNER');
const instanceOwner = new WeakMap();

/**
`EmberObject` is the main base class for all Ember objects. It is a subclass
Expand All @@ -30,8 +30,10 @@ export default class EmberObject extends CoreObject {
}

get [OWNER]() {
if (this[OVERRIDE_OWNER]) {
return this[OVERRIDE_OWNER];
let owner = instanceOwner.get(this);

if (owner !== undefined) {
return owner;
}

let factory = FACTORY_FOR.get(this);
Expand All @@ -41,7 +43,7 @@ export default class EmberObject extends CoreObject {
// we need a setter here largely to support
// folks calling `owner.ownerInjection()` API
set [OWNER](value) {
this[OVERRIDE_OWNER] = value;
instanceOwner.set(this, value);
}
}

Expand Down