REFACTOR: Remove Discourse constant from get-owner

This commit is contained in:
Robin Ward
2020-08-19 15:41:11 -04:00
parent 185ed80702
commit 347a4981a0
7 changed files with 68 additions and 38 deletions

View File

@ -1,14 +1,20 @@
import deprecated from "discourse-common/lib/deprecated";
import { getOwner as emberGetOwner } from "@ember/application";
import { getOwner as emberGetOwner, setOwner } from "@ember/application";
let _default = {};
export function getOwner(obj) {
if (emberGetOwner) {
return emberGetOwner(obj) || Discourse.__container__;
return emberGetOwner(obj) || emberGetOwner(_default);
}
return obj.container;
}
export function setDefaultOwner(container) {
setOwner(_default, container);
}
// `this.container` is deprecated, but we can still build a container-like
// object for components to use
export function getRegister(obj) {