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

[mediaqueries] Define more precisely the evaluation of media queries #8056

Closed
cdoublev opened this issue Nov 10, 2022 · 1 comment
Closed

Comments

@cdoublev
Copy link
Collaborator

Section 3.1 is Evaluating Media Queries but it does not even define how to evaluate <media-query-list>, <media-query>, <media-type>, but only non top-level subproductions. How to evaluate them is actually defined:

  • for <media-query-list>: in 2.1 Combining Media Queries with A media query list is true if any of its component media queries are true, and false only if all of its component media queries are false
  • for <media-query>: in 2. Media Queries with a media query is true if: the media type, if specified, matches the media type of the device where the user agent is running, and the media condition is true.
  • for <media-type>: in 2.3 Media Types with User agents must recognize the following media types as valid, but must make them match nothing

In my opinion, it would help to have some consistency by using "evaluates to true" instead of "is true", or "must evaluate" instead of "must recognize" or "must match", to make a clear distinction between parsing and evaluating, even if both could apply at the same time.


Each of the major subexpression of <media-condition> or <media-condition-without-or> is associated with a boolean result

It may be obvious to experienced implementers but I am not one of them and how and when the major subexpression of <media-condition> or <media-condition-without-or> is associated with a boolean result is not really clear to me, and some general guidance would have been helpfull, like in the introduction of 5. Parsing in CSS Syntax.

I know that evaluating media queries is required at parse time to decide whether the style sheet referenced by @import must be fetched, and at computed value time to filter the declared values (but also as part of the event loop and when running window.matchMedia()). This answers the "when".

I do not think that the result from their evaluation should be assigned as a property of the result from parsing these productions. It would be useless since it would have to be updated each time the definition of the user environment has changed.

MediaQueryList seems like a good fit to make this association: it holds the result from parsing <media-query-list> and returns its evaluation. It could hold an internal state that optimize running an evaluation depending on which media feature of the user environment has changed. But there is no mention of MediaQueryList in the Media Queries spec, except in a note about custom media queries that is obscure to me, so I am not sure about this idea.

@gsnedders
Copy link
Member

This is effectively a duplicate of #7594 and #7595.

@gsnedders gsnedders closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2022
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

No branches or pull requests

2 participants