mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-15 16:02:32 +08:00
21 lines
505 B
JavaScript
21 lines
505 B
JavaScript
import { $el } from "./ui.js";
|
|
|
|
export async function addStylesheet(urlOrFile, relativeTo) {
|
|
return new Promise((res, rej) => {
|
|
let url;
|
|
if (urlOrFile.endsWith(".js")) {
|
|
url = urlOrFile.substr(0, urlOrFile.length - 2) + "css";
|
|
} else {
|
|
url = new URL(urlOrFile, relativeTo ?? `${window.location.protocol}//${window.location.host}`).toString();
|
|
}
|
|
$el("link", {
|
|
parent: document.head,
|
|
rel: "stylesheet",
|
|
type: "text/css",
|
|
href: url,
|
|
onload: res,
|
|
onerror: rej,
|
|
});
|
|
});
|
|
}
|