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

Split box shadows on top-level commas only #7479

Merged
merged 2 commits into from
Feb 23, 2022

Conversation

thecrypticace
Copy link
Contributor

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:

  1. var(--a,
  2. 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

@thecrypticace thecrypticace force-pushed the fix/box-shadow-parsing-with-var branch 2 times, most recently from 33e25d6 to 3d93086 Compare February 15, 2022 18:45
@thecrypticace thecrypticace merged commit 04686b8 into master Feb 23, 2022
@thecrypticace thecrypticace deleted the fix/box-shadow-parsing-with-var branch February 23, 2022 16:31
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.

Bug: box shadow with color method can be compiled with missing parentheses
1 participant