Skip to content

Commit 5d4cb84

Browse files
authored
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 57048ac commit 5d4cb84

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

lib/internal/event_target.js

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 7 deletions
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)