DEV: Support `registerWaiter` import in legacy env (#16195)
Throw in `unregisterWaiter` too
This commit is contained in:
parent
c58c2f53e8
commit
704606e731
|
@ -164,6 +164,10 @@ var define, requirejs;
|
|||
"@ember/object/internals": {
|
||||
guidFor: Ember.guidFor,
|
||||
},
|
||||
"@ember/test": {
|
||||
registerWaiter: Ember.Test.registerWaiter,
|
||||
unregisterWaiter: Ember.Test.unregisterWaiter,
|
||||
},
|
||||
I18n: {
|
||||
// eslint-disable-next-line
|
||||
default: I18n,
|
||||
|
|
|
@ -3,6 +3,8 @@ import { PUBLIC_JS_VERSIONS } from "discourse/lib/public-js-versions";
|
|||
import { Promise } from "rsvp";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { run } from "@ember/runloop";
|
||||
import { isTesting } from "discourse-common/config/environment";
|
||||
import { registerWaiter } from "@ember/test";
|
||||
|
||||
const _loaded = {};
|
||||
const _loading = {};
|
||||
|
@ -14,8 +16,9 @@ function loadWithTag(path, cb) {
|
|||
let s = document.createElement("script");
|
||||
s.src = path;
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
Ember.Test?.registerWaiter(() => finished);
|
||||
if (isTesting()) {
|
||||
registerWaiter(() => finished);
|
||||
}
|
||||
|
||||
s.onload = s.onreadystatechange = function (_, abort) {
|
||||
finished = true;
|
||||
|
|
Loading…
Reference in New Issue