Re: [cssom] Constructor for MediaList

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