Skip to content

Commit 3dcdab3

Browse files
deokjinkimRafaelGSS
authored andcommitted
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: #46054 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent 8684dae commit 3dcdab3

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

lib/internal/event_target.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ class EventTarget {
561561
weak,
562562
} = validateEventListenerOptions(options);
563563

564+
validateAbortSignal(signal, 'options.signal');
565+
564566
if (!validateEventListener(listener)) {
565567
// The DOM silently allows passing undefined as a second argument
566568
// No error code for this since it is a Warning
@@ -575,8 +577,6 @@ class EventTarget {
575577
}
576578
type = String(type);
577579

578-
validateAbortSignal(signal, 'options.signal');
579-
580580
if (signal) {
581581
if (signal.aborted) {
582582
return;

test/wpt/status/dom/events.json

-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
]
99
}
1010
},
11-
"AddEventListenerOptions-signal.any.js": {
12-
"fail": {
13-
"expected": [
14-
"Passing null as the signal should throw (listener is also null)"
15-
]
16-
}
17-
},
1811
"Event-constructors.any.js": {
1912
"fail": {
2013
"expected": [

0 commit comments

Comments
 (0)