Re: [CSSOM View] MediaQueryList as EventTarget

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 UTC