Re: [mediaqueries][css-values] Empty string value <media-query> or not

On Tue, 30 Sep 2014 12:05:54 +0200, Simon Pieters <simonp@opera.com> wrote:

> What is the correct interpretation of this grammar:
>
> a? | b

Admittedly, this is is a bit weird syntax, but IIRC, this is meant to be  
equivalent to this "( a | b )?". One, or the other, or nothing, but not  
both.

> This is relevant for  
> http://dev.w3.org/csswg/mediaqueries-4/#typedef-media-query
>
> In particular, consider this media query list: ","
>
> If the empty string matches <media-query> production then there are two  
> empty <media-query>s (it's not defined if it matches or not AFAICT).
>
> If the empty string does not match <media-query> production then it's  
> equivalent to "not all,not all" per the error recovery rules (this  
> matches Trident/WebKit/Blink/Gecko/Presto).

http://dev.w3.org/csswg/mediaqueries-4/#media says:

    "A media query is a logical expression that is either true or false. 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 all specified  
media
     features are true."

Combining this with the interpretation of the grammar above, it means that  
an empty media query is allowed, and true. Which meads that "," is  
allowed, and true.

I agree that this may not be overly clearly worded, but I think if you  
look hard enough, I think it is not ambiguous.

> If the interoperable browser behavior is intended, please remove the  
> question mark.

I don't remember that this deviation from interoperable behavior is  
intentional.

"@media {...}" should definitely match, but given that we have interop,  
"@media ,  {...}" should not.

Which means we need (as you suggested) to change the <media-query>  
production to this:
<media-condition> | [ not | only ]? <media-type> [ and <media-condition> ]?

While we're at it, we may also want to be explicit that the  
media-query-list can be an empty list, by adding "This list may be empty."  
at the end of the second paragraph in section 3  
(http://dev.w3.org/csswg/mediaqueries4/#mq-syntax)

  - Florian

Received on Tuesday, 30 September 2014 16:07:40 UTC