Skip to content

Register preference and interaction media features#221

Open
jhaygood86 wants to merge 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/preference-media-features
Open

Register preference and interaction media features#221
jhaygood86 wants to merge 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/preference-media-features

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Summary

Registers seven preference/interaction media features so they parse as typed media features instead of degrading to not all (an unregistered feature makes the whole @media query fail):

prefers-color-scheme, prefers-reduced-motion, prefers-contrast, prefers-reduced-transparency, update, any-hover, any-pointer (Media Queries 5).

Each is a trivial modeling addition — a MediaFeature subclass whose converter is Converters.Any (accept-and-preserve), the same shape ExCSS's other discrete features use — plus a FeatureNames constant and a MediaFeatureFactory registration. Registration only; no evaluation/matching is added (ExCSS does no media evaluation).

Tests

PreferenceMediaFeaturesTests — asserts each of the 7 now parses and round-trips inside @media (…) rather than degrading to not all, plus a guard that a genuinely unknown feature (prefers-nonsense) still degrades (proving the assertions are meaningful). Full suite green across all target frameworks.

Ported from PeachPDF, which vendors ExCSS.

Add typed media-feature registrations for the Media Queries 4/5
preference and interaction features so they model as concrete media
features instead of degrading to an UnknownMediaFeature (which drops the
whole query to "not all"):

  prefers-color-scheme, prefers-reduced-motion, prefers-contrast,
  prefers-reduced-transparency, update, any-hover, any-pointer

Each feature accepts and preserves its value via Converters.Any; this is
registration/parsing only, with no query evaluation. Adds the feature
name constants, one MediaFeature subclass per feature, and the factory
registrations.

Spec: https://www.w3.org/TR/mediaqueries-5/
@jhaygood86
jhaygood86 marked this pull request as ready for review July 24, 2026 20:01
@jhaygood86
jhaygood86 marked this pull request as draft July 24, 2026 20:35
@jhaygood86
jhaygood86 marked this pull request as ready for review July 24, 2026 20:35
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.

1 participant