W3C home > Mailing lists > Public > www-style@w3.org > September 2014

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 30 Sep 2014 18:01:11 -0400
Message-ID: <CAAWBYDC9z4u14k5Y2e06=6CCtR=4+4FHkVvvK7UbW7f5xK70uQ@mail.gmail.com>
To: Florian Rivoal <florian@rivoal.net>
Cc: www-style list <www-style@w3.org>, Simon Pieters <simonp@opera.com>
On Tue, Sep 30, 2014 at 12:07 PM, Florian Rivoal <florian@rivoal.net> wrote:
> 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.

A little bit weird, but completely unambiguous for grammars - you can
take the first branch, which happens to match either "a" or "".
Nothing strange about that.

>> 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.

MQ3 didn't allow an empty MQ; I'm pretty sure this was a mistake,
probably introduced by me, and we should remove the offending question
mark.

>> 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)

Sure.

~TJ
Received on Tuesday, 30 September 2014 22:01:58 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:46 UTC