Switch to promise for style loading

This commit is contained in:
Nicholas Jitkoff 2022-06-16 18:49:38 -07:00
parent fb82baf22d
commit dad7603612

View file

@ -24,9 +24,13 @@ function async(u, c) {
}
function loadSyle(href, callback) {
document.head.appendChild(el("link", { type: "text/css", rel: "stylesheet", href, onload:callback}));
let promise = new Promise((resolve, reject) => {
document.head.appendChild(el("link", { type: "text/css", rel: "stylesheet", href, onload:resolve}));
})
return callback ? promise.then(callback) : promise;
}
function renderScriptContent(data, origin) {
var base = el('base', {href: data});
document.head.appendChild(base);