mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
events: check signal before listener
In WPT Events, TypeError is expected if both listener and signal are null. But checking listener doesn't throw TypeError. So check signal before listener because checking signal throws TypeError if signal is null. PR-URL: https://github.com/nodejs/node/pull/46054 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
@@ -561,6 +561,8 @@ class EventTarget {
|
||||
weak,
|
||||
} = validateEventListenerOptions(options);
|
||||
|
||||
validateAbortSignal(signal, 'options.signal');
|
||||
|
||||
if (!validateEventListener(listener)) {
|
||||
// The DOM silently allows passing undefined as a second argument
|
||||
// No error code for this since it is a Warning
|
||||
@@ -575,8 +577,6 @@ class EventTarget {
|
||||
}
|
||||
type = String(type);
|
||||
|
||||
validateAbortSignal(signal, 'options.signal');
|
||||
|
||||
if (signal) {
|
||||
if (signal.aborted) {
|
||||
return;
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"AddEventListenerOptions-signal.any.js": {
|
||||
"fail": {
|
||||
"expected": [
|
||||
"Passing null as the signal should throw (listener is also null)"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Event-constructors.any.js": {
|
||||
"fail": {
|
||||
"expected": [
|
||||
|
||||
Reference in New Issue
Block a user