Fix issue with @apply
rules not generating all the rules when the target is comma separated
#3678
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.
Fixes #3360, Fixes #3154, Fixes #3306
TW has an issue generating rules during
@apply
when the target selector is part of a comma separated list of selectors (unless you're applying the first selector in a comma separated set). All three issues related to@apply
have this root cause. Trying to manipulate a comma separated list and getting the right output with no duplicates causing specificity issues is tricky, however there's a shortcut which is to flatten the incoming CSS before starting.So
becomes
before we even start processing. The downside(?) is that the development mode CSS files become larger (about 25k larger). But the upside is that I believe all the
@apply
bugs are fixed. The duplicates are recombined during production builds by cssnano, so there's no production downside.(Edit: example now uses slightly modified version of @RobinMalfait's comment #3360 (comment))
Input
Was
Is now
@RobinMalfait I believe this is why you didn't see the issue when you created the test, but you did see it in the playground - you need the target to be in a list.