Fetch styles async

Co-authored-by: vee <vendicated@riseup.net>
This commit is contained in:
CodeF53 2024-07-09 15:23:16 -04:00 committed by GitHub
parent 5ac7ed6b18
commit a3bbe21e92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,9 +9,8 @@
export async function getStyles(): Promise<string> {
let out = "";
const styleLinkNodes: NodeListOf<HTMLLinkElement> = document.querySelectorAll('link[rel="stylesheet"]');
for (const styleLinkNode of styleLinkNodes)
out += await parseStyleLinkNode(styleLinkNode);
return out;
return Promise.all(styleLinkNodes.map(n => parseStyleLinkNode(n)))
.then(contents => contents.join("\n"));
}
// runs callback with styles of new style nodes added to the head