Skip to content

Commit 816e6de

Browse files
authored
fix: correct constructable stylesheet feature detection (#271)
1 parent 55ea807 commit 816e6de

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/base/src/CSS.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const _createStyle = (tagName, styleContent) => {
2424
}
2525

2626
let style;
27-
if (window.CSSStyleSheet) {
27+
if (document.adoptedStyleSheets) {
2828
style = createConstructableStyleSheet(styleContent);
2929
} else {
3030
style = createStyleElement(styleContent);

packages/base/src/WebComponent.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class WebComponent extends HTMLElement {
6565
return;
6666
}
6767
const newStyle = createStyle(this.constructor);
68-
if (window.CSSStyleSheet) {
68+
if (document.adoptedStyleSheets) {
6969
this.shadowRoot.adoptedStyleSheets = [newStyle];
7070
} else {
7171
const oldStyle = this.shadowRoot.querySelector("style");
@@ -86,7 +86,7 @@ class WebComponent extends HTMLElement {
8686
const shadowDOM = await ShadowDOM.prepareShadowDOM(this.constructor);
8787
this.shadowRoot.appendChild(shadowDOM);
8888

89-
if (window.CSSStyleSheet) {
89+
if (document.adoptedStyleSheets) {
9090
const style = createStyle(this.constructor);
9191
this.shadowRoot.adoptedStyleSheets = [style];
9292
}

0 commit comments

Comments
 (0)