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)
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/
Updated•9 years ago
|
Component: Untriaged → DOM: CSS Object Model
Product: Firefox → Core
Looks like the spec was changed in https://hg.csswg.org/drafts/rev/ce11bd9d0293 to address https://www.w3.org/Bugs/Public/show_bug.cgi?id=25304
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)
Updated•9 years ago
|
Whiteboard: btpp-fixlater
Blocks: 1270626
Reporter | ||
Comment 2•8 years ago
|
||
Looks like this works now. Resolving.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•