-
-
Notifications
You must be signed in to change notification settings - Fork 39
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: Support scoping inner elements of a webc file #5
Comments
Reclassifying this one as a bug |
I’m waffling back and forth here because I do kinda think this is okay and as a better short term solution I’d like to ship an example of how to override the |
Makes sense. I don't know of any css scoping libraries myself, but that would be a cool thing to find |
also worth mentioning that native scoping is coming and it might be good to start thinking about it. for example, webc could manage a unique hash to pass inside |
This is still important as long as scoped prefixing occurs before transforming... currently, the CSS being fed to a preprocessor is not what the developer wrote, but the result of applying the prefix transform. This creates unintended side effects. |
Assumption about the current state:
If I have the file:
After compilation I would currently see:
Main concern:
For components that wrap another component, this isn't scoped enough to prevent style leakage. For example if our component above had a child component within it, and that child component also contained an
h1
element, then.wcl2xedjk h1
would apply and turn italiceblue
.Desired behaviour:
In Svelte's CSS scoping, I can write the following:
Which would provide me something along the psuedo-lines of
Where the styles are scoped directly to the elements they applied to.
Implementation:
In (my) ideal world this would happen automatically when
webc:scoped
is applied. Alternatively to keep it opt-in it one could utilize something like a:host
pseudo-class wrapping styles:Ideally slightly more complex selectors would also be handled, so
h1 + p:first-child
could becomeh1.qwerty + p.asdfgh:first-child
The text was updated successfully, but these errors were encountered: