Re: [cssom-view] why not MediaQueryList.onchange

On Mon, Mar 31, 2014 at 11:38 PM, Simon Pieters <simonp@opera.com> wrote:

> On Mon, 31 Mar 2014 23:25:13 +0200, Jochen Eisinger <eisinger@google.com>
> wrote:
>
>  On Mon, Mar 31, 2014 at 11:17 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>>
>>  On 3/31/14 4:51 PM, Jochen Eisinger wrote:
>>>
>>>  The reason I ask is because MediaQueryListListener is a pretty unique
>>>> snowflake in the web exposed APIs
>>>>
>>>>
>>> It is?  It's just a WebIDL callback function.  There are tons of them in
>>> the platform: event handlers, audio API callbacks, geolocation callbacks,
>>> mutation observer callbacks, WebRTC callbacks of various sorts, Web
>>> Components callbacks, requestAnimationFrame, probably more that I'm
>>> missing.  What's the unique aspect of MediaQueryListListener?
>>>
>>
>>
>> The other callbacks don't have a property that gets invoked, it's e.g.
>> setTimeout(function() { ..}, 42) and not setTimeout({timeout: function() {
>> ...}}, 42);
>>
>
> MediaQueryListListener doesn't have a property that gets invoked either,
> per spec.
>

I see, I guess I was confused by reading
https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryListListenerinstead
of the spec.

In any case, I still don't understand the benefit of using
addListener/removeListener over defining a change event?

best
-jochen


>
> [[
> interface MediaQueryList {
>   readonly attribute DOMString media;
>   readonly attribute boolean matches;
>   void addListener(MediaQueryListListener listener);
>   void removeListener(MediaQueryListListener listener);
> };
>
> callback MediaQueryListListener = void (MediaQueryList list);
> ]]
> http://dev.w3.org/csswg/cssom-view/#mediaquerylist
>
> WebIDL: http://heycam.github.io/webidl/#idl-callback-functions
>
> It is not a callback *interface*. http://heycam.github.io/
> webidl/#dfn-callback-interface
>
> --
> Simon Pieters
> Opera Software
>

Received on Monday, 31 March 2014 21:50:08 UTC