W3C home > Mailing lists > Public > www-style@w3.org > June 2013

Re: [cssom] Constructor for MediaList

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 26 Jun 2013 10:18:21 -0700
Message-ID: <CAAWBYDByz5TrN9vhYN3pS_9e+TUXCrz0wfz53jD9H6xPOryDUA@mail.gmail.com>
To: Simon Sapin <simon.sapin@exyr.org>
Cc: Simon Pieters <simonp@opera.com>, Glenn Adams <glenn@skynav.com>, "www-style@w3.org" <www-style@w3.org>
On Wed, Jun 26, 2013 at 4:22 AM, Simon Sapin <simon.sapin@exyr.org> wrote:
> Le 25/06/2013 18:42, Tab Atkins Jr. a écrit :
>> Instead, we can directly address this by allowing the value of a
>> custom MQ to be set to a MediaList, with the meaning being that it has
>> the same truth value as the contained MQs:
>>
>> <script>
>> document.css.customMedia.set("foo", new MediaList("(foo:bar) and
>> (baz:qux)"));
>> </script>
>> <style>
>> @media "foo" {
>>    ...
>> }
>> </style>
>
> Why is a constructor needed instead of just a string?
>
> document.css.customMedia.set("foo", "(foo:bar) and (baz:qux)");

Because a custom MQ should be settable to a string as well, so you can
do ("foo": "bar"), similar to existing MQs that let you test for
specific values.

Basically, custom MQs should be settable to booleans, strings, or
numbers.  Setting them to another MQ is a special form of
auto-updating boolean.

~TJ
Received on Wednesday, 26 June 2013 17:19:08 UTC

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