DEV: Set owner on widget instances (#22391)

This allows us to use `getOwner(this)` on widgets (without needing to resort to our custom `discourse-common/lib/get-owner` implementation which has a hacky fallback)
This commit is contained in:
David Taylor 2023-07-03 17:34:24 +01:00 committed by GitHub
parent 0790e9f4f1
commit 1b693d0d60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -42,5 +42,7 @@ export function getRegister(obj) {
},
};
setOwner(register, owner);
return register;
}

View File

@ -24,6 +24,7 @@ import { get } from "@ember/object";
import { h } from "virtual-dom";
import { isProduction } from "discourse-common/config/environment";
import { consolePrefix } from "discourse/lib/source-identifier";
import { getOwner, setOwner } from "@ember/application";
const _registry = {};
@ -146,6 +147,7 @@ export default class Widget {
this.dirtyKeys = opts.dirtyKeys;
register.deprecateContainer(this);
setOwner(this, getOwner(register));
this.key = this.buildKey ? this.buildKey(attrs) : null;
this.site = register.lookup("service:site");