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": {
|
"@ember/object/internals": {
|
||||||
guidFor: Ember.guidFor,
|
guidFor: Ember.guidFor,
|
||||||
},
|
},
|
||||||
|
"@ember/test": {
|
||||||
|
registerWaiter: Ember.Test.registerWaiter,
|
||||||
|
unregisterWaiter: Ember.Test.unregisterWaiter,
|
||||||
|
},
|
||||||
I18n: {
|
I18n: {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
default: I18n,
|
default: I18n,
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { PUBLIC_JS_VERSIONS } from "discourse/lib/public-js-versions";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { run } from "@ember/runloop";
|
import { run } from "@ember/runloop";
|
||||||
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
import { registerWaiter } from "@ember/test";
|
||||||
|
|
||||||
const _loaded = {};
|
const _loaded = {};
|
||||||
const _loading = {};
|
const _loading = {};
|
||||||
|
@ -14,8 +16,9 @@ function loadWithTag(path, cb) {
|
||||||
let s = document.createElement("script");
|
let s = document.createElement("script");
|
||||||
s.src = path;
|
s.src = path;
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
if (isTesting()) {
|
||||||
Ember.Test?.registerWaiter(() => finished);
|
registerWaiter(() => finished);
|
||||||
|
}
|
||||||
|
|
||||||
s.onload = s.onreadystatechange = function (_, abort) {
|
s.onload = s.onreadystatechange = function (_, abort) {
|
||||||
finished = true;
|
finished = true;
|
||||||
|
|
Loading…
Reference in New Issue