Repository navigation
[style-value-parser] Support boolean-context media features like (prefers-reduced-motion) - #1911
Open
henryqdineen wants to merge 2 commits into
Open
henryqdineen wants to merge 2 commits into
henryqdineen wants to merge 2 commits into
Conversation
…fers-reduced-motion) Expand the word-rule parser's allowed list to the Media Queries Level 4/5 features so queries like `@media (prefers-reduced-motion)` no longer throw. Fixes meta#1909 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Collaborator
Author
|
Note on CI: the |
2 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed / motivation ?
@media (prefers-reduced-motion)and other media features evaluated in a boolean context threwInvalid media query syntax, because the word-rule parser only allowedcolor,monochrome,gridandcolor-index.This expands the list to the Media Queries Level 4/5 features (
hover,pointer,any-*,prefers-*,forced-colors,scripting, range features, etc.). Queries are emitted as written, with no normalization: for most features the boolean form isn't equivalent to a single value (e.g.(pointer)matches bothfineandcoarse).The allowed names live in one
as constarray;WordRuleis derived from it and the guard is aSetlookup. Flow can't verify aSet.hastype guard, so it uses$FlowFixMe[incompatible-type-guard], matchingTokenParser.string.Linked PR/Issues
Fixes #1909
Additional Context
Added round-trip parser tests for
(prefers-reduced-motion),(prefers-contrast),(hover),(any-pointer),(forced-colors)and a combinedandquery, plus a test that an unknown feature ((prefers-reduce-motion)) still throws.Pre-flight checklist
🤖 Generated with Claude Code