-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
:not() selector not working properly with pseudoclasses #14168
Comments
+1, ran into this as well on several selectors of the form: |
It's not just pseudo-classes — see example from #14169 https://svelte.dev/playground/7e9220bafc094e209bb9a53e7e7bb48d?version=5.1.10 |
Also can be triggered from attributes: https://svelte.dev/playground/7028eeed4643409c860ce6fee36c05ca?version=5.1.10 |
My mistake was to turn the logic around for all matches, not just the static ones. Static matches are those for static classes, for |
I don't draw that conclusion — I think we can probably do this (pseudocode): if (!could_match(selector, node)) {
- return false;
+ return is_not;
}
return true; // this bit stays the same In other words 'definitely matches' becomes 'definitely does not match' if you're dealing with a Tinkering in that direction but I'm not going to get it finished before I need to leave for the evening |
fixes #14168 This reverts the whole "selectors inside `:not` are scoped" logic. Scoping is done so that styles don't bleed. But within `:not`,everything is reversed, which means scoping the selectors now means they are more likely to bleed. That is the opposite of what we want to achieve, therefore we should just leave those selectors alone.
fixes #14168 This reverts the whole "selectors inside `:not` are scoped" logic. Scoping is done so that styles don't bleed. But within `:not`,everything is reversed, which means scoping the selectors now means they are more likely to bleed. That is the opposite of what we want to achieve, therefore we should just leave those selectors alone. The exception are `:not` selectors with descendant selectors, as that means "look up the tree" and we need to scope all ancestor elements in that case.
Describe the bug
As of 5.1.10, selectors like
:not(:last-child)
are getting erroneously detected as unused.Reproduction
https://svelte.dev/playground/hello-world?version=5.1.10#H4sIAAAAAAAACm2NQQvCMAyF_0rJaQN17FqH4M3bLt6ch7lGOojNaKNzjP13W3DgwVPyvpf3MoNrHwgaTkjEamRPRmVoekGTwwbuPWEAfZlBpiHdJRD5N3Uchl14IUlitzbgP96xE3QSa6Cy5aF2WBVxNi6p88i_ynpc3UiCTIRpFVtqx5JpaoNsO9uTydWcjEY6JvZaeTT7BJaYK9Zg_C74FtDin7hclw8dQ5rQ7wAAAA==
This does work in the previous version, presumably because we weren't trying to scope the
:not()
- https://svelte.dev/playground/hello-world?version=5.1.9#H4sIAAAAAAAACm2NQQvCMAyF_0rJaQN17FqH4M3bLt6ch7lGOojNaKNzjP13W3DgwVPyvpf3MoNrHwgaTkjEamRPRmVoekGTwwbuPWEAfZlBpiHdJRD5N3Uchl14IUlitzbgP96xE3QSa6Cy5aF2WBVxNi6p88i_ynpc3UiCTIRpFVtqx5JpaoNsO9uTydWcjEY6JvZaeTT7BJaYK9Zg_C74FtDin7hclw8dQ5rQ7wAAAA==Logs
Unused CSS selector "h1:not(:last-child)" (css_unused_selector)
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: