You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 14, 2024. It is now read-only.
// Apply the stylesheet to a Shadow Root:constnode=document.createElement('div');constshadow=node.attachShadow({mode: 'open'});shadow.adoptedStyleSheets=[sheet];
Notice that we're overriding the value of adoptedStyleSheets instead of changing the array in place. This is required because the array is frozen; in-place mutations like push() throw an exception, so we have to assign a new array. To preserve any existing StyleSheets added via adoptedStyleSheets, we can use concat to create a new array that includes the existing sheets as well as additional ones to add
Since this article was created, there have been some great changes to adoptedStylesheets, specifically adoptedStyleSheets.push is now allowed and adoptedStyleSheets is not immutable anymore.
Proposed changes to the article
Using adoptedStyleSheets.push in the example code
Removing the paragraph about adoptedStyleSheets being immutable and in-place mutations not being allowed