[csswg-drafts] [cssom][cssom-view] Not clear what should happen if matchMedia is called with empty string

upsuper has just created a new issue for 
https://github.com/w3c/csswg-drafts:

== [cssom][cssom-view] Not clear what should happen if matchMedia is 
called with empty string ==
In [CSSOM View 
spec](https://drafts.csswg.org/cssom-view/#dom-window-matchmedia):
> Let *parsed media query list* be the result of 
[parsing](https://drafts.csswg.org/cssom/#parse-a-media-query-list) 
query

In [CSSOM 
spec](https://drafts.csswg.org/cssom/#parse-a-media-query-list):
> To ***parse a media query list*** for a given string s into a media 
query list is defined in the Media Queries specification. Return the 
list of one or more media queries that the algorithm defined there 
gives.

Clearly the definition of this algorithm in Media Queries spec should 
not allow empty string, because otherwise something like `@media {}` 
would be legal. So empty string is something need to be handled in 
either CSSOM View spec or CSSOM spec.

The other callsite of CSSOM spec's **parse a media query list** 
algorithm I found is in the setter of 
[`MediaList.mediaText`](https://drafts.csswg.org/cssom/#dom-medialist-mediatext),
 whose algorithm explicitly avoids calling the above algorithm with 
empty string. And in which case, it would leave `MediaList` to be an 
empty list (which isn't interoperable currently, though).

So I guess CSSOM View spec should say something when `matchMedia` is 
called with an empty string.

Currently, browsers are interoperable to some extent. All browsers 
seem to agree it is effectively equal to an `all`, while Firefox and 
Chrome return empty string for `MediaQueryList.media`, and Edge 
returns `all` for that.

Please view or discuss this issue at 
https://github.com/w3c/csswg-drafts/issues/700 using your GitHub 
account

Received on Thursday, 10 November 2016 03:51:43 UTC