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

Re: [CSSOM View] MediaQueryList as EventTarget

From: Anne van Kesteren <annevk@opera.com>
Date: Fri, 15 Jun 2012 09:26:56 +0200
To: "www-style list" <www-style@w3.org>, "Dean Jackson" <dino@apple.com>
Message-ID: <op.wfxoa6w364w2qv@annevk-macbookpro.local>
On Fri, 15 Jun 2012 03:25:00 +0200, Dean Jackson <dino@apple.com> wrote:
> The MediaQueryList interface has addListener and removeListener methods,  
> that each take a MediaQueryListListener (which is a pretty cool name  
> when you think about it).
>
> MediaQueryListListener has a single handleChange() method.
>
> Is there a good reason why MediaQueryList isn't just an EventTarget? It  
> makes more sense to me, and would allow you to have a single controller  
> object to implement handleEvent for all your code. As it currently  
> stands, it is a weird handleChange method.

Events seem like overkill for this, but now we have proper callbacks it  
should be made somewhat simpler:

...
   void addListener(MediaQueryListCallback callback);
   void removeListener(MediaQueryListCallback callback);
};

callback MediaQueryListCallback = void (MediaQueryList mql);

(Could be named MediaQueryListListener still if we want to keep that for  
extra coolness, the name is not exposed anywhere.)


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Friday, 15 June 2012 07:27:32 GMT

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