Repository navigation
Keep all parent selectors inside :not() - #179
Open
wahidrizka wants to merge 1 commit into
Open
wahidrizka wants to merge 1 commit into
wahidrizka wants to merge 1 commit into
Conversation
With a selector list as the parent, & inside :not() was replaced with
one parent selector per rule, so `.a, .b { .x:not(&) {} }` gave
`.x:not(.a), .x:not(.b)`, which also matches `.x.a`. Sass and native
CSS nesting put the whole list inside: `.x:not(.a, .b)`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed in #176.
With a selector list as the parent,
&inside:not()was replaced with one parent selector per rule, which turns "neither.anor.b" into "not.a, or not.b":Now
&inside:not()gets the whole parent list in its own selector list, also inside:is(),:where()or:has()within:not(), and several&there take every combination, like top-level&since #176. Outside:not()nothing changes, so.x:is(&)still gives.x:is(.a), .x:is(.b).:not(:nth-child(2n of &))also keeps the old output, because the part afterofis not a plain selector list.To check it, I compared the output with Sass on distinct generated nested rules that use
&inside:not()in different ways. On main, 1,333 of 2,699 rules gave a different set of selectors, now none do (another seed: 1,324 of 2,651, now none). On 4,000 more distinct general rules, 143 more now match Sass and none stopped matching. In Chrome 154, the output now styles the same elements as native nesting in all 6 cases I tried, main differed in 5.(Edited: my first numbers counted some generated rules twice. These count each distinct rule once.)
The new test fails on main.
bnt --coverage 100,oxlintandoxfmt --checkpass.