Skip to content

Commit d95723b

Browse files
authored
Create passShadowDom
1 parent 1a7cf7d commit d95723b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

passShadowDom

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Takes a node, CSSResult and appends it
3+
*/
4+
export const applyStyle = (node: LitElement, style: CSSResult) => {
5+
if ("adoptedStyleSheets" in document) {
6+
const sheets = node.shadowRoot.adoptedStyleSheets;
7+
node.shadowRoot.adoptedStyleSheets = [...sheets, style._styleSheet];
8+
} else {
9+
const styleNode = document.createElement("style");
10+
styleNode.textContent = style.cssText;
11+
node.shadowRoot.appendChild(styleNode);
12+
}
13+
};

0 commit comments

Comments
 (0)