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

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

From: Sylvain Galineau <sylvaing@microsoft.com>
Date: Thu, 15 Apr 2010 13:48:21 +0000
To: Anne van Kesteren <annevk@opera.com>, www-style list <www-style@w3.org>
Message-ID: <045A765940533D4CA4933A4A7E32597E211EAB1D@TK5EX14MBXC113.redmond.corp.microsoft.com>
To be clear: you're saying that @media { ... } is invalid, right ? Thus
WebKit treats it correctly  ?

If so we should clarify this part of the prose. I honestly don't see how anyone
could understand that these two opening statements have nothing to do
with syntax, nor how it relates to what model.

Second, can you elaborate on why Gecko's OM behavior makes sense ?
To the extent no medium is invalid, I can see how 'not all' allows the rule
to be disabled when all have been removed. I assume it also allows new 
mediums to be inserted afterwards and apply (although patterns like 'print 
not all' ought to be explained in the spec).

Any other reasons ?

From: Anne van Kesteren [annevk@opera.com]
Sent: Thursday, April 15, 2010 2:34 AM
To: www-style list; Sylvain Galineau
Subject: Re: [css3-mediaqueries][cssom] Empty media queries in stylesheets and the DOM

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

Received on Thursday, 15 April 2010 13:48:57 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:13:45 UTC