Re: [mediaqueries] Error handling for media-condition

> On 22 Sep 2015, at 21:51, Simon Pieters <simonp@opera.com> wrote:
> 
> https://drafts.csswg.org/mediaqueries-4/#error-handling seems only concerned about media queries, not so much media condition. <img sizes> uses a media condition, not a media query.

This is meant to be covered in the previous section. A large subset of incorrect syntax for media conditions should be caught by the <general-enclosed> part of the grammar.


>  Please state in the spec:
> 
> * What should happen when a media condition doesn't match the grammar?

If the failure to match the grammar is so bad that it won't even trigger the general-enclosed handling, then you fail to match the syntax for the entire media query (not the entire media query list), and this is handled in the section you linked to.

If you fall into the general enclosed, then the part of  https://drafts.csswg.org/mediaqueries-4/#mq-syntax that starts with "Each of the major terms of <media-condition> or <media-condition-without-or> is associated with a boolean result, as follows" should tell you how it is evaluated. This uses three-value logic (true, false and unknown) rather than regular boolean logic (and the note at the end of the section is meant to explain why.

> * What should happen when a media condition has an unknown <mf-name> or <mf-value>, or disallowed <mf-value>?

I believe that this is meant to be treated as unknown, like general-enclosed, but I don't think the spec is actually saying this explicitly, or clearly enough. It should.

How about this change

  "When parsing the <media-in-parens> production, the <general-enclosed> branch must only be chosen if the input does not match either of the preceding branches."

  ->

"When parsing the <media-in-parens> production, the <general-enclosed> branch must only be chosen if the input does not match either of the preceding branches, or if the input does match one of the preceding branch but uses <mf-name>s or <mf-value>s not supported by the UA."

> * If the result of a media condition is unknown, should it match or not?

Quoting from the spec:

"<media-condition>
<media-condition-without-or>
<media-in-parens>
  The result is the result of the child term."

and

"If the result of a media query is unknown, it must be treated as false for the purpose of matching."

In other words, if the top-leve media condition of a media query is unknown, it is treated as false. If the media conditions is nested into something else, the the unknown value propagates up, and is handled according to the logic described in each of the various things that might contain it (media-not, media-and, media-or).

 - Florian

Received on Wednesday, 23 September 2015 07:36:54 UTC