W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2010

Re: Extending CSSOM Views matchMedium with callback

From: Anne van Kesteren <annevk@opera.com>
Date: Tue, 11 May 2010 08:40:13 +0200
To: "Simon Fraser" <smfr@me.com>, "L. David Baron" <dbaron@dbaron.org>
Cc: "Luiz Agostini" <luiz.agostini@openbossa.org>, public-webapps@w3.org, www-style@w3.org
Message-ID: <op.vci3hbe064w2qv@annevk-t60>
On Mon, 10 May 2010 19:56:41 +0200, L. David Baron <dbaron@dbaron.org>  
wrote:
> On Monday 2010-05-10 10:27 -0700, Simon Fraser wrote:
>> It feels to me like the correct solution would be enhance CSS OM  
>> somehow to allow
>> authors to attach event listeners to CSSMediaRules somehow, so they can  
>> get notified
>> when those @media statements start or stop matching.
>
> Making @media rules implement EventTarget sounds ok, as long as the
> events don't bubble.  But is the main use case for this API actually
> people who already have @media rules, or people who want to do
> things separately from @media rules and would thus now have to go
> through the bother of adding some to a style sheet?  (The CSSOM also
> isn't very good at giving you the rule object after adding a rule.)
>
> I might still lean towards an
> addMediaQueryListener/removeMediaQueryListener type API.

Yeah, if @media was enough we would not have needed to provide the  
matchMedium() abstraction.

   styleMedia.addMediumListener(mq, callback)
   styleMedia.removeMediumListener(mq, callback)

Sounds good to me. With the same semantics as addEventListener(). (I.e.  
duplicates removed, invoked in order of registration.)


And as context information the media query and how it currently evaluates?  
What kind of representation for the media query? Serialized form?


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Tuesday, 11 May 2010 06:41:20 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:38 GMT