Bug 156730
| Summary: | MediaQueryList.addListener does not support Object with handleEvent() method | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | nkronlage |
| Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | ashvayka |
| Priority: | P2 | ||
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
nkronlage
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/
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Alexey Shvayka
*** This bug has been marked as a duplicate of bug 203288 ***