addGlobalStyle could be refactored to add to the current node's root node, rather than defaulting to the document.
export function addGlobalStyle(id: string, style: string, node: Element) {
const rootNode = node.getRootNode()
if (rootNode.getElementById(id)) return
const elem = document.createElement('style')
elem.id = id
elem.innerHTML = style
if (rootNode instanceof Document) {
rootNode.head.appendChild(elem)
} else {
rootNode.head.appendChild(elem)
}
}
That should work, I'm not sure if this is useful. Would it only apply when used client-side and/or does it make sense in the desired best usage (static generation)?
addGlobalStylecould be refactored to add to the current node's root node, rather than defaulting to the document.That should work, I'm not sure if this is useful. Would it only apply when used client-side and/or does it make sense in the desired best usage (static generation)?