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

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

From: Sylvain Galineau <sylvaing@microsoft.com>
Date: Thu, 15 Apr 2010 00:49:11 +0000
To: www-style list <www-style@w3.org>
Message-ID: <045A765940533D4CA4933A4A7E32597E211EA949@TK5EX14MBXC113.redmond.corp.microsoft.com>
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.

On my Win7 laptop, Firefox 3.6.3 and Opera 10.51 treat @media {...}  like 
@media all { ... }. Safari 4.0.3 and Chrome 4.1 ignore the @media rule.

As it is currently specified, however, Safari and Chrome comply with the media query 
syntax defined in CSS2.1[2] and CSS3 Media Queries[3], where both the media_list (2.1) 
and media_query_list (CSS3) productions require at least one media type/medium IDENT.

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' ?


[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
Received on Thursday, 15 April 2010 00:49:48 GMT

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