[Webkit-unassigned] [Bug 156730] New: MediaQueryList.addListener does not support Object with handleEvent() method

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Apr 18 22:18:56 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=156730

            Bug ID: 156730
           Summary: MediaQueryList.addListener does not support Object
                    with handleEvent() method
    Classification: Unclassified
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: CSS
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: nkronlage at hotmail.com

Repro:

    var query = matchMedia("(min-width: 400px)");

    var listener = {
      handleEvent: function() {
        document.body.style.background = query.matches ? 'red' : 'blue';
      }
    }

    query.addListener(listener);
    listener.handleEvent();

Runnable:  https://jsfiddle.net/j4278otv/

Running this results in the error: "[Error] TypeError: Argument 1 ('listener') to MediaQueryList.addListener must be a function"

The spec (https://drafts.csswg.org/cssom-view/#mediaquerylist) says the parameter to addListener is an EventListener (https://dom.spec.whatwg.org/#callbackdef-eventlistener): 

    callback interface EventListener {
      void handleEvent(Event event);
    };

but the implementation only allows functions.

The Node.addEventListener method does support the Object with handleEvent() method:  See https://jsfiddle.net/6nL0epf3/

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160419/55d5e0ad/attachment-0001.html>


More information about the webkit-unassigned mailing list