Fix guard against concurrently loading of assets.

This commit is contained in:
Guo Xiang Tan 2017-07-17 13:04:30 +09:00
parent c5401a0927
commit d613f3f559

View File

@ -36,7 +36,8 @@ export default function loadScript(url, opts) {
opts = opts || {}; opts = opts || {};
$('script').each((i, tag) => { $('script').each((i, tag) => {
_loaded[tag.getAttribute('src')] = true; const src = tag.getAttribute('src');
if (src) _loaded[tag.getAttribute('src')] = true;
}); });
@ -57,12 +58,12 @@ export default function loadScript(url, opts) {
}); });
const cb = function(data) { const cb = function(data) {
_loaded[url] = true;
if (opts && opts.css) { if (opts && opts.css) {
$("head").append("<style>" + data + "</style>"); $("head").append("<style>" + data + "</style>");
} }
done(); done();
resolve(); resolve();
_loaded[url] = true;
}; };
let cdnUrl = url; let cdnUrl = url;