Skip to content

Commit 8607445

Browse files
committed
fix touse validateAbortSignal to check signal
1 parent a10f689 commit 8607445

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/internal/event_target.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const {
3434
ERR_INVALID_THIS,
3535
}
3636
} = require('internal/errors');
37-
const { validateObject, validateString, validateInternalField } = require('internal/validators');
37+
const { validateAbortSignal, validateObject, validateString, validateInternalField } = require('internal/validators');
3838

3939
const {
4040
customInspectSymbol,
@@ -575,9 +575,7 @@ class EventTarget {
575575
}
576576
type = String(type);
577577

578-
if (signal === null) {
579-
throw new ERR_INVALID_ARG_TYPE('options.signal', 'AbortSignal', signal);
580-
}
578+
validateAbortSignal(signal, 'options.signal');
581579

582580
if (signal) {
583581
if (signal.aborted) {

test/parallel/test-whatwg-events-add-event-listener-options-signal.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ const {
160160
}
161161
{
162162
const et = new EventTarget();
163-
throws(() => et.addEventListener('foo', () => {}, { signal: null }), {
164-
name: 'TypeError',
163+
[1, {}, null, false, 'hi'].forEach((signal) => {
164+
throws(() => et.addEventListener('foo', () => {}, { signal }), {
165+
name: 'TypeError',
166+
});
165167
});
166168
}

0 commit comments

Comments
 (0)