-
Notifications
You must be signed in to change notification settings - Fork 378
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
CSS encapsulation and common CSS rules #800
Comments
Yes, there's constructable stylesheets. Part of that proposal was |
@andyearnshaw Thanks. That answers my third question. |
Sorry, skim read and didn't answer the whole thing. Currently, there's no way to apply CSS to descendant shadow trees. There's a shadow parts proposal that would enable a component author to expose parts of the descendant shadow trees. There's no way to style arbitrary elements inside a shadow tree, there were selectors for this originally but they were dropped from the specification and are not supported by any browser implementations that are based on the "v1" spec. |
Yeah, let me summarize, and close the issue.
|
Since the op asked 'deprecated or not' there was also an early stab at combinators for 'drilling down' but those received some bad feedback and directions changed. |
@bkardell |
I believe you should be able to link to an external style sheet from within the Shadow DOM. I've been wanting something similar since 2005. Just because the style sheet is external, doesn't mean its rules must apply to anything outside of the shadow dom that contains that link. I have some custom elements that recur on a page one hundred times. It seems wasteful (upon inspecting the document's shadow dom nodes) that each of those shadow dom nodes contains an identical copy of a pretty lengthy set of CSS rules within each shadowDom's style tag. Wouldn't it be more efficient if each shadow dom could linked to an external style sheet instead? The browser would cache that external resource after the first download of it, and use that cache for each recurring element's link to that same sheet. I realize, that no matter where a style comes from, the browser still has to apply that style just as much, and it could be, that behind the scenes the browser is doing something way more efficient that what appear so redundant during document inspection. Yet, on the surface it appears excessively redundant and I've been wanting the ability to link to external style sheets, from within components (with component-level scope), for a long time now. @hayatoito mentioned constructable-stylesheets, I'm reading about it now. |
|
The browser would do this for all sub-resources regardless of where they appear. Browser engines can also cache the result of parsed CSS, etc... whenever the same CSS appears in multiple shadow trees. Constructable stylesheets, if implemented in WebKit, will probably be not anymore efficient than just using style element in each shadow tree in any meaningful way. |
@emilio : When ShadowDOM is supposed to encapsulate style. I'd consider it a bug if it doesn't also do this when an external style sheet is imported into the shadowDOM. |
I need contructable stylesheets in Firefox! |
Yes it does. |
That should work fine in all browsers now. That's sort of the whole point of shadow DOM. |
Currently(deprecated or not) is there a way to apply CSS to children shadow DOMs?
Are all future plans for CSS encapsulation to not allow a way for parent DOMs to affect children shadow DOMs?
Duplicating CSS for each shadow DOM to achieve common CSS rules leads to a waste of resources. Is there a way for or any plans for references to style elements, etc., so that common css can be created once and referenced multiple times by other DOMs?
The text was updated successfully, but these errors were encountered: