fix: bug where page wouldn't complete loading if data.scripts was emptied

isekai-main
Julian Lam 3 years ago
parent 2a89ad8288
commit 578145acd6

@ -344,7 +344,7 @@ ajaxify = window.ajaxify || {};
// Require and parse modules // Require and parse modules
let outstanding = data.scripts.length; let outstanding = data.scripts.length;
data.scripts.map(function (script) { const scripts = data.scripts.map(function (script) {
if (typeof script === 'function') { if (typeof script === 'function') {
return function (next) { return function (next) {
script(); script();
@ -369,14 +369,20 @@ ajaxify = window.ajaxify || {};
}; };
} }
return null; return null;
}).filter(Boolean).forEach(function (fn) { }).filter(Boolean);
fn(function () {
outstanding -= 1; if (scripts.length) {
if (outstanding === 0) { scripts.forEach(function (fn) {
callback(); fn(function () {
} outstanding -= 1;
if (outstanding === 0) {
callback();
}
});
}); });
}); } else {
callback();
}
}); });
}; };

Loading…
Cancel
Save