w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 661 forks source link

[mediaqueries] `min-` or `max-` prefixed `<mf-name>` in `<mf-range>` #8044

Open cdoublev opened 2 years ago

cdoublev commented 2 years ago

What should be the behavior when evaluating a min- or max- prefixed <mf-name> in <mf-range>?

Attempting to evaluate a min/max prefixed media feature in a boolean context is invalid and a syntax error.

Should it be in a boolean or range context? But please also note that this sentence seems to mix the concept of parsing (syntax error) and evaluating (cf. https://github.com/w3c/csswg-drafts/issues/8056), and that later in the spec (in an example in 3.2 Error Handling), min-orientation is said to be considered an unknown media feature.

Also, the expected evaluation is not clear for discrete media feature names. The above sentence seems to conflict with the sentence that comes just before:

“Discrete” type properties do not accept “min-” or “max-” prefixes. Adding such a prefix to a “discrete” type media feature simply results in an unknown feature name.

tabatkins commented 1 year ago

Hm, yes, that looks like an oversight. (min-height < 500px) should definitely be an error.

cdoublev commented 1 year ago

Do you mean that it should be a parse error? Chrome seems to evaluate it as unknown (but not FF).

matchMedia('(min-width) or (min-width < 1px) or (color)')

Also, it would make a difference between known vs. unknown media feature names: the latter are defined as evaluating to unknown.

An unknown <mf-name> or <mf-value>, or a feature value which does not matches the value syntax for that media feature, results in the value “unknown”.

In my opinion, both sentences should be removed, only the above definition should stay.