Skip to content

Commit

Permalink
fix: correct constructable stylesheet feature detection (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
pskelin authored Mar 28, 2019
1 parent 55ea807 commit 816e6de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/base/src/CSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const _createStyle = (tagName, styleContent) => {
}

let style;
if (window.CSSStyleSheet) {
if (document.adoptedStyleSheets) {
style = createConstructableStyleSheet(styleContent);
} else {
style = createStyleElement(styleContent);
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/WebComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class WebComponent extends HTMLElement {
return;
}
const newStyle = createStyle(this.constructor);
if (window.CSSStyleSheet) {
if (document.adoptedStyleSheets) {
this.shadowRoot.adoptedStyleSheets = [newStyle];
} else {
const oldStyle = this.shadowRoot.querySelector("style");
Expand All @@ -86,7 +86,7 @@ class WebComponent extends HTMLElement {
const shadowDOM = await ShadowDOM.prepareShadowDOM(this.constructor);
this.shadowRoot.appendChild(shadowDOM);

if (window.CSSStyleSheet) {
if (document.adoptedStyleSheets) {
const style = createStyle(this.constructor);
this.shadowRoot.adoptedStyleSheets = [style];
}
Expand Down

0 comments on commit 816e6de

Please sign in to comment.