Split box shadows on top-level commas only #7479
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.
Splitting by commas "not inside parens" isn't quite possible with regex without recursion and the JS flavor of regex doesn't support this. It's possible that this could be worked around with regex for finite levels of nesting (say… handling up to 5 or something) but that seems like more trouble than it's worth.
The previous behavior caused us to split strings like
var(--a, 0 0 1px rgb(0, 0, 0))
into two parts:var(--a,
0 0 1px rgb(0, 0, 0))
The first which is considered an invalid shadow and the 2nd a valid one (even though there's an extra
)
laying around. I think the best solution for now is to not try to detect box shadows in variables but treat this as a raw shadow that doesn't get parsed. This, at the very least, will now not generate invalid CSS that gets thrown out.cc @adamwathan I think you worked on the colored box shadow support here. Does this seem like a reasonable compromise or should we try to parse/replace the box shadow inside variable default values?
Fixes #7347