Closed Bug 1265622 Opened 9 years ago Closed 8 years ago

MediaQueryList.addListener does not support Object with handleEvent() method (convert MediaQueryListListener to EventListener)

Categories

(Core :: DOM: CSS Object Model, defect)

47 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1354441

People

(Reporter: neil.kronlage, Unassigned)

References

Details

(Whiteboard: btpp-fixlater)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36 Steps to reproduce: 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/ Actual results: In the console, you get the following error: TypeError: Argument 1 of MediaQueryList.addListener is not callable. Expected results: 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/
Component: Untriaged → DOM: CSS Object Model
Product: Firefox → Core
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: MediaQueryList.addListener does not support Object with handleEvent() method → MediaQueryList.addListener does not support Object with handleEvent() method (convert MediaQueryListListener to EventListener)
Whiteboard: btpp-fixlater
Looks like this works now. Resolving.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
Looks like this got fixed in bug 1354441.
Resolution: WORKSFORME → DUPLICATE
You need to log in before you can comment on or make changes to this bug.