mirror of
https://github.com/arfct/itty-bitty.git
synced 2026-03-11 08:54:33 +00:00
Switch to promise for style loading
This commit is contained in:
parent
fb82baf22d
commit
dad7603612
1 changed files with 5 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue