You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EventTarget.addEventListener specifies that browsers should terminate and ignore the call if the callback is null:
If callback is null, terminate these steps.
However, it's unclear about what should happen if the callback is not a function/not a callable.
Take the following source, which is clearly a misuse:
document.addEventListener("click",42);
The callback is not null, so according to the spec, there is no reason to ignore the addEventListener call here. However, browsers behave different. In Chrome, the call simply gets ignored, acting as if the callback would be null. In Firefox, however, we throw an exception since a Number is not callable.
To avoid further issues and to make it easier for vendors to adjust their implementations, a note should be added to the spec, saying that the call should be terminated if the callback not callable.
The text was updated successfully, but these errors were encountered:
Fill file a Chrome bug. Also, Safari Technology Preview also throws, so this is the way to go. I'll throw a link here to the Chrome report, but I'll close this issue nonetheless, since it is actually covered in the WebIDL (sorry, did miss that).
EventTarget.addEventListener
specifies that browsers should terminate and ignore the call if the callback is null:However, it's unclear about what should happen if the callback is not a function/not a callable.
Take the following source, which is clearly a misuse:
The callback is not
null
, so according to the spec, there is no reason to ignore theaddEventListener
call here. However, browsers behave different. In Chrome, the call simply gets ignored, acting as if the callback would benull
. In Firefox, however, we throw an exception since a Number is not callable.To avoid further issues and to make it easier for vendors to adjust their implementations, a note should be added to the spec, saying that the call should be terminated if the callback not callable.
The text was updated successfully, but these errors were encountered: