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

Re: [cssom-view] addMediumListener / removeMediumListener

From: Anne van Kesteren <annevk@opera.com>
Date: Mon, 31 May 2010 14:57:26 +0200
To: "Simon Fraser" <smfr@me.com>
Cc: "Luiz Agostini" <luiz.agostini@openbossa.org>, www-style@w3.org, marcosc@opera.com
Message-ID: <op.vdkl90tl64w2qv@annevk-t60>
On Thu, 27 May 2010 17:59:32 +0200, Simon Fraser <smfr@me.com> wrote:
> It would be better to change it to matchMedia() now, rather than later,  
> since not many people are using this yet. I hope we can avoid more  
> renames, though. Or, if we accept media query lists, maybe it should  
> just be be matchQueryList(), which I think is easier to read than the  
> awkward "matchMedium". matchQuery() would also work OK.

Given those I guess we should go with matchMedia / addMediaListener /  
removeMediaListener to match @media and media="" which both also accept  
media query lists.

Then we need to answer the question how to compare media query lists. The  
suggestions from Luiz make sense but would also affect what  
MediaList.mediaText returns. The order would suddenly be different. But  
although that difference may seem larger I suppose it is not very  
different from the other normalization steps that are taking place.


> I'm  a little concerned about using a BooleanCallback here. I agree that  
> there's an issue where the serialized query may not match what was  
> originally used to add the listener, but I think having some context in  
> the callback is necessary. This allows people writing OOP JS to have a  
> single object with a handleEvent() function which can act as a listener  
> for multiple queries. This would be slightly easier if there were an  
> easy way to re-serialize a query (i.e. to convert it to its canonical  
> form) via some API.
>
> A slightly hacky alternative would be for addMediumListener() to return  
> a token (like setTimeout()) that can be used to identify which listener  
> is it, and gets passed to the callback.

Does that give a convenient API though? You would need to keep some table  
around with the mapping from token to media query list. We could go back  
to having an object that exposes the serialized media query list. Getting  
a serialized media query list is easy enough by getting to a MediaList  
object somehow and getting its mediaText attribute. Don't think we need to  
create a convenient shorthand for that right away.


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Monday, 31 May 2010 12:58:21 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:27 GMT