Closed
Bug 1335588
Opened 9 years ago
Closed 9 years ago
addEventListener should not throw a TypeError if the callback is not callable
Categories
(Core :: DOM: Events, defect, P3)
Core
DOM: Events
Tracking
()
RESOLVED
INVALID
People
(Reporter: denschub, Unassigned)
References
Details
(Whiteboard: [webcompat])
Given the following example:
> document.addEventListener("click", 42);
In Firefox, we throw a TypeError about not being able to call "42". In Chrome, this call simply gets ignored.
Us throwing an exception is breaking some websites since it stops the JS flow. The spec clearly claims to ignore the call if the callback is null, and we should drop it if it's not callable, so we don't break stuff and to have parity with Chrome.
I've opened a spec issue at [0], and there is a WebCompat issue attached.
[0]: https://github.com/whatwg/dom/issues/405
Comment 1•9 years ago
|
||
We don't throw when null is passed, per DOM spec, and throw when invalid value is passed, per WebIDL spec.
Need a spec change before doing anything here, but this really sounds like a bug in Chrome.
Updated•9 years ago
|
Priority: -- → P3
| Reporter | ||
Comment 2•9 years ago
|
||
Yes, it is actually a bug in Chromium, and in fact, bz already filed it: https://bugs.chromium.org/p/chromium/issues/detail?id=676845
Closing this as invalid. Thanks!
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•