Re: [cssom-view] addMediumListener / removeMediumListener

Is there any compelling reasons to not accept media query lists?

A useful notification may be related to a list and not to a specific query.
For example I could have

@media (min-width: 300px), (orientation:landscape) {
    body {background-color: red}
}

and be interested on receiving a callback when the background color of the
body changes. It is of course possible to make it just having callbacks to
each query but having a callback to the list would make it somewhat easier.

On a side note, the matchMedium implementation in WebKit accepts media query
lists, is that to be considered a bug?

2010/5/26 Anne van Kesteren <annevk@opera.com>

> On Tue, 25 May 2010 18:05:39 +0200, Luiz Agostini <
> luiz.agostini@openbossa.org> wrote:
>
>> 1 - The text refers to media query. Is it a media_query or a
>> media_query_list as defined in
>> http://www.w3.org/TR/css3-mediaqueries/#syntax? I assume it is about a
>> media_query_list. The serialization rules for a list of media queries do
>> not mention any sorting of the queries in the list and thus is not good for
>> comparison because it would then lead to "(color) and (min-width: 100px)"
>> != (min-width: 100px) and (color)" for example. Should serialization rules
>> for a list of media queries change?
>>
>
> The text talks about "parse a media query" which is quite clearly defined
> in:
>
> http://dev.w3.org/csswg/cssom/#parse-a-media-query
>
> I.e. it only accepts a single media query.
>
>
>
>  2 - Is mediaText really needed as parameter of MediaQueryCallbacks? Being
>> a serialization of the media query it may be different of the original query
>> and user would not have an easy way to recognize it. In other hand it may be
>> very easy to provide this kind of information to callbacks using Javascript
>> closures. For example:
>>
>> function mediumCallback(query, value)
>> {
>>    alert(query + " = " + value);
>> }
>>
>> function addMediumListener(query)
>> {
>>    window.styleMedia.addMediumListener(query, mediumCallback);
>> }
>>
>> addMediumListener("tv and (color)");
>>
>> Any kind of information may be supplied to the callbacks this way and the
>> media query, specially the serialized media query,  may not necessarily the
>> most useful information in all situations.
>>
>
> Fair enough. I've made it BooleanCallback and added a closure example (the
> corrected one). And also a simple usage example.
>
>
>
>  3 - Is the order in which the callbacks must be called specified?
>>
>
> Yes, there's an ordered list which is only appended to. I've added the word
> "ordered" to make this more clear :-)
>
>
> Thanks a lot for giving feedback so quickly!
>
>
>
> --
> Anne van Kesteren
> http://annevankesteren.nl/
>

Received on Wednesday, 26 May 2010 14:07:42 UTC