-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Compound global selector check is too restrictive #9207
Comments
The selector makes little sense, it claims two conflicting things. In words it would be something like: "The element is from this component, its attribute is maybe from somewhere else." I only see three real alternatives here:
Your workaround is also contradictory, it will just lead to a selector with the scoping class If I am missing something, please give a concrete example with markup showing what you are trying to do here. |
@brunnerh The selector I'm using does make sense, as shown here: #6222. I need it because, just like the example in the issue shown, the data-attribute comes from a svelte action.
I'd express it differently:
I need the scoping, as the element is present in the markup.
Requiring a container for this is a bad workaround IMO. If doing
This won't trigger, as the data-attribute comes from an action.
It's not contradictory, it's exactly what I want, but I'd love to not have .anim-checkbox twice. Here is a REPL illustrating the issue https://svelte.dev/repl/f6fb6eb216aa440881a8a9bac03def6f?version=4.2.0 |
I see the issue now. Svelte is being stingy in applying the scoping class to the elements, it only does so if it detects a matching selector in the CSS. (Which is probably a reasonable thing to do, especially in SSR, where everything needs to be transmitted as well.) Other workarounds are:
So I agree with you, this kind of selector has to be allowed, my mistake. |
This works quite well! Thank you for the suggestion 😄
Hmm, this did not work on my REPL to be honest 🤔
No worries. I'd love to add a contribution myself, will try and give it a go. No idea how to get started but I've always wanted to contribute directly to Svelte. |
Right, that only works if there also is an element which statically matches the scoped selector. |
Describe the bug
I was trying to do the following:
But received an error:
:global(...) not at the start of a selector sequence should not contain type or universal selectors(css-invalid-global-selector-position)
Digging into Svelte's issues, I found that this check comes from issue #6272. I fear the fix implemented is too restrictive, as I think my syntax would be perfectly valid.
For now, I have this work-around:
Reproduction
Write the following into any
style
tag in a.svelte
file:Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: