Skip to content

[style-value-parser] Support boolean-context media features like (prefers-reduced-motion) - #1911

Open
henryqdineen wants to merge 2 commits into
meta:mainfrom
henryqdineen:hqd-media-boolean-features
Open

henryqdineen wants to merge 2 commits into
meta:mainfrom
henryqdineen:hqd-media-boolean-features

Conversation

@henryqdineen

Copy link
Copy Markdown
Collaborator

What changed / motivation ?

@media (prefers-reduced-motion) and other media features evaluated in a boolean context threw Invalid media query syntax, because the word-rule parser only allowed color, monochrome, grid and color-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 both fine and coarse).

The allowed names live in one as const array; WordRule is derived from it and the guard is a Set lookup. Flow can't verify a Set.has type guard, so it uses $FlowFixMe[incompatible-type-guard], matching TokenParser.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 combined and query, plus a test that an unknown feature ((prefers-reduce-motion)) still throws.

Pre-flight checklist

🤖 Generated with Claude Code

…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]>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 28, 2026
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
stylex Ignored Ignored Oct 10, 2026 5:29am UTC

Request Review

@henryqdineen

henryqdineen commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Note on CI: the packages and prettier failures are pre-existing on main (from border-radius.test.js) and unrelated to this PR. #1907 fixes them.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support boolean evaluation for media features like @media (prefers-reduced-motion)

1 participant