W3C home > Mailing lists > Public > www-style@w3.org > March 2015

[mediaqueries] @media screen and (foo) or (baz)

From: Simon Sapin <simon.sapin@exyr.org>
Date: Mon, 23 Mar 2015 17:08:27 +0100
Message-ID: <55103A7B.4070200@exyr.org>
To: www-style list <www-style@w3.org>
MQ Level 4 extends the syntax to allow arbitrary nesting of "not", 
"and", and "or" boolean operators. It avoids the question of whether `A 
or B and C` should be interpreted as `A or (B and C)` or `(A or B) and 
C` by requiring the parentheses:

Extract of the grammar:

> <media-condition> = <media-not> | <media-and> | <media-or> | <media-in-parens>
> <media-not> = not <media-in-parens>
> <media-and> = <media-in-parens> [ and <media-in-parens> ]+
> <media-or> = <media-in-parens> [ or <media-in-parens> ]+
> <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed>


However, there is one case left that may seem ambiguous. The 
<media-query> grammar:

> <media-query> = <media-condition>
>              | [ not | only ]? <media-type> [ and <media-condition> ]?

accepts `<media-type> and <media-or>`, e.g. `screen and (foo) or (bar)`.

The grammar makes it unambiguously the same as `screen and ((foo) or 
(bar))`, but that’s not obvious without referring to the spec.


Should the grammar be restricted to require parenthenses in this case as 
well?

-- 
Simon Sapin
Received on Monday, 23 March 2015 16:08:59 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:30 UTC