-
Notifications
You must be signed in to change notification settings - Fork 168
[ShadyCSS] Constructible Stylesheets and adoptedStyleSheets support for browsers with native shadow DOM #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
While implementing this enhancement, please mind the CSP (Content-Security-Policy). Some applications may have a very strict policy (e.g. forbid inline anonymous CSSStyleSheet = class extends originalCSSStyleSheet {
(...)
fixCsp(nonce) {
this._styleElement.nonce = nonce;
}
} This would result in attaching |
@justinfagnani, the construct-styles-sheets-polyfill project may be interesting for you. It supports the
It can also be used along with the ShadyCSS's |
CSSStyleSheet is not instantiable, so it's not extensible either ... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen! |
Constructible Stylesheets
We want to support and API as close as possible to native Constructible Stylesheets, so that this works:
This may be achievable by overwriting the CSSStyleSheet constructor with one that creates a stylesheet in a shadow root. Something like:
(I haven't tried this code)
adoptedStyleSheets
ShadowRoot.adoptedStyleSheets
could be implemented with a setter that only accepts arrays of stylesheets created as above with a_styleElement
property. It would then clone those style elements and insert them last into the shadow root.To protect against mutations of the shadow root that remove the styles, we can put them in a custom element called
<adopted-stylesheets>
that adds itself back to the shadow root if it's ever removed.allAdoptedStylesheets
can be used to update cloned style tags incasereplace
orreplaceSync
is called on a CSSStyleSheet.cc @azakus
The text was updated successfully, but these errors were encountered: