mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
FIX: Register a test waiter rather than using hidden properties
This commit is contained in:
@ -5,13 +5,16 @@ const _loading = {};
|
||||
function loadWithTag(path, cb) {
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
|
||||
let finished = false;
|
||||
let s = document.createElement('script');
|
||||
s.src = path;
|
||||
if (Ember.Test) { Ember.Test.pendingAjaxRequests++; }
|
||||
if (Ember.Test) {
|
||||
Ember.Test.registerWaiter(() => finished);
|
||||
}
|
||||
head.appendChild(s);
|
||||
|
||||
s.onload = s.onreadystatechange = function(_, abort) {
|
||||
if (Ember.Test) { Ember.Test.pendingAjaxRequests--; }
|
||||
finished = true;
|
||||
if (abort || !s.readyState || s.readyState === "loaded" || s.readyState === "complete") {
|
||||
s = s.onload = s.onreadystatechange = null;
|
||||
if (!abort) {
|
||||
|
Reference in New Issue
Block a user