Disallow using multiple selectors in arbitrary variants #10655
Merged
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.
When given a utility like
[div,span_&]:p-1
we would previously generate just a rule fordiv
effectively chopping off the variant at the,
even though that portion of the selector doesn't include a "nesting" marker to tell us where the candidate goes in the selector. This is also a problem because it would match every div no matter what.Arbitrary variants were not intended to support multiple selectors at all and the fact that this produces any rules is a bug. Furthermore, if you put
[span_&,div_&]:p-1
into Tailwind CSS today it doesn't generate anything (as intended) making the idea that this could be relied on and/or useful even less likely.This PR fixes this by splitting on commas at the top-level and discarding candidates that have multiple selectors. Note that you can still use commas in a class name when it is escaped. For example:
[.span\,div_&]:p-1
.Fixes #10576