Skip to content

Commit

Permalink
fix: No style sheet found warning
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Sep 24, 2024
1 parent ea9c6d2 commit b2004ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/js/media-theme-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,12 @@ export class MediaThemeElement extends globalThis.HTMLElement {
render(): void {
this.renderer?.update(this.props);

const { style } = getOrInsertCSSRule(this.renderRoot, ':host');
if (style.visibility === 'hidden') {
style.removeProperty('visibility');
// The style tag must be connected to the DOM before it has a sheet.
if (this.renderRoot.isConnected) {
const { style } = getOrInsertCSSRule(this.renderRoot, ':host');
if (style.visibility === 'hidden') {
style.removeProperty('visibility');
}
}
}
}
Expand Down

0 comments on commit b2004ba

Please sign in to comment.