v4: Allow hyphen character in regex pattern to use support queries as is #13596
+34
−2
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.
It looks like matching for the hyphen character in the existing regex to use support queries as-is resolves #13594.
This might be a good long-term solution anyway, as it covers any future function syntaxes added to support queries, as well as supporting CSS var definition rules:
Tests:
'supports-gap:grid'
->@supports (gap: var(--tw))
'supports-[display:grid]:flex'
->@supports (display: grid)
'supports-[selector(A_>_B)]:flex'
->@supports selector(A > B)
'supports-[font-format(opentype)]:grid'
->@supports font-format(opentype)
'supports-[content:"("]:grid'
->@supports (content: "(")
'supports-[(display:grid)_and_font-format(opentype)]:grid'
->@supports (display: grid) and font-format(opentype)
'supports-[font-tech(color-COLRv1)]:flex'
->@supports font-tech(color-COLRv1)
'supports-[--test]:flex'
->@supports (--test: var(--tw))
The one failing rule, recommended by @adamwathan in #13594, appears to have not worked before either and likely requires a slight change to the parser to account for consuming chars in quoted strings in arbitrary values as-is, including special chars.
Testing
supports-[content:"("]
againstsupports-[content:"test"]
confirmed the parenthesis as the problematic character, as expected, so that should be a relatively simple fix.As that effort does not appear directly related to issue #13594, I prefer to handle that one in a separate PR, and I do intend to take my best shot at it so that I can get a bit less rusty at rust 😅