W3C home > Mailing lists > Public > www-style@w3.org > April 2010

Re: [css3-mediaqueries][cssom] Empty media queries in stylesheets and the DOM

From: Anne van Kesteren <annevk@opera.com>
Date: Thu, 15 Apr 2010 18:34:44 +0900
To: "www-style list" <www-style@w3.org>, "Sylvain Galineau" <sylvaing@microsoft.com>
Message-ID: <op.va6576nb64w2qv@annevk-t60>
On Thu, 15 Apr 2010 09:49:11 +0900, Sylvain Galineau  
<sylvaing@microsoft.com> wrote:
> Section 2 of the specification [1] states:
>> A media query consists of a media type and zero or more expressions
>> involving media features. If the media type is omitted it is assumed
>> to be 'all'.
>
> It is unclear whether the second statement means a) that this:
>
>    @media { ... }
>
> ...is equivalent to:
>
>    @media all { ... }
>
> ...or b) whether it only means that:
>
>    @media (orientation:portrait) { ... }
>
> ...is equivalent to:
>
>    @media all and (orientation:portrait) { ... }
>
> ...but that @media { ... } is otherwise invalid.

It actually only means something on the model level. Nothing on the syntax  
level. The syntax is described in a different section and the syntax for  
@media is described somewhere else altogether.


> Things get more confusing at the DOM level.
>
> If one specifies an @media all {...} rule and then removes the 'all'  
> medium using MediaList.deleteMedium()[4], Firefox then returns 'not all'  
> for MediaList.mediaText.
> Consistent with this media query value, the content of the @media rule  
> no longer
> applies and the relevant elements' style is updated accordingly.
>
> In this same case, Opera returns an empty string for the mediaText  
> property, and,
> consistent with its handling of @media {...}, still applies the styles  
> defined in
> the rule.
>
> Safari and Chrome return the empty string but do not refresh the styles  
> originally
> applied by the @media all {...} rule (although I haven't verified  
> whether that is
> true for all properties).
>
> Overall, Opera seems to be the most consistent implementation in this  
> scenario, if
> not the only conformant one.
>
> Questions:
> 1. Is Opera's implementation the correct one ?
>    - If not because the prose intended b) above then we should clarify  
> the prose
>    and define the handling of empty media query strings in CSSOM's  
> MediaList interface.
> 2. If Opera is correct because the spec intended to specify a) above then
>    - Isn't the media_query_list grammar in CSS3 Media Queries incorrect ?
>    - Should MediaList.mediaText and MediaList.appendMedium() serialize  
> empty
>    media query strings to 'all' ?

I think what Gecko does makes some sense. It's consistent with how invalid  
media queries ought to behave. The details are not completely tied down  
unfortunately because they are separately defined and Media Queries is in  
CR already...


> [1] http://www.w3.org/TR/css3-mediaqueries/#media0
> [2] http://www.w3.org/TR/CSS2/grammar.html#grammar
> [3] http://www.w3.org/TR/css3-mediaqueries/#syntax
> [4] http://dev.w3.org/csswg/cssom/#dom-medialist-deletemedium


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Thursday, 15 April 2010 09:35:31 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:26 GMT