Skip to content
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

Disallow using multiple selectors in arbitrary variants #10655

Merged
merged 8 commits into from
Feb 22, 2023

Conversation

thecrypticace
Copy link
Contributor

When given a utility like [div,span_&]:p-1 we would previously generate just a rule for div 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

@thecrypticace thecrypticace merged commit 9bbdd9b into master Feb 22, 2023
@thecrypticace thecrypticace deleted the fix/disallow-multi-selector-arbitrary-variants branch February 22, 2023 19:44
@reinink reinink changed the title Disallow multi-selector arbitrary variants Disallow using multiple selectors in arbitrary variants Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to list multiple variants in arbitrary variant
1 participant