GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — events: add null check for the signal of EventTarget · nodejs/node@03fb789

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • event_target.js
  • test
    • parallel
      • test-whatwg-events-add-event-listener-options-signal.js
    • wpt/status/dom
      • events.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/event_target.js‎

Copy file name to clipboardExpand all lines: lib/internal/event_target.js
+3-1Lines changed: 3 additions & 1 deletion
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,6 +575,8 @@ class EventTarget {
575575
}
576576
type = String(type);
577577

578+
validateAbortSignal(signal, 'options.signal');
579+
578580
if (signal) {
579581
if (signal.aborted) {
580582
return;
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-events-add-event-listener-options-signal.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require('../common');
44

55
const {
66
strictEqual,
7+
throws,
78
} = require('assert');
89

910
// Manually ported from: wpt@dom/events/AddEventListenerOptions-signal.any.js
@@ -157,3 +158,11 @@ const {
157158
}, { once: true });
158159
et.dispatchEvent(new Event('foo'));
159160
}
161+
{
162+
const et = new EventTarget();
163+
[1, 1n, {}, [], null, true, 'hi', Symbol(), () => {}].forEach((signal) => {
164+
throws(() => et.addEventListener('foo', () => {}, { signal }), {
165+
name: 'TypeError',
166+
});
167+
});
168+
}
Collapse file

‎test/wpt/status/dom/events.json‎

Copy file name to clipboardExpand all lines: test/wpt/status/dom/events.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"AddEventListenerOptions-signal.any.js": {
1212
"fail": {
1313
"expected": [
14-
"Passing null as the signal should throw",
1514
"Passing null as the signal should throw (listener is also null)"
1615
]
1716
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.