Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6ea12e

Browse filesBrowse files
benjamingrcodebytere
authored andcommitted
lib: set abort-controller toStringTag
PR-URL: #36115 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8390f8a commit d6ea12e
Copy full SHA for d6ea12e

File tree

Expand file treeCollapse file tree

3 files changed

+24
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+24
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/abort_controller.js‎

Copy file name to clipboardExpand all lines: lib/internal/abort_controller.js
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const {
77
ObjectAssign,
88
ObjectDefineProperties,
99
ObjectSetPrototypeOf,
10+
ObjectDefineProperty,
1011
Symbol,
12+
SymbolToStringTag,
1113
TypeError,
1214
} = primordials;
1315

@@ -55,6 +57,13 @@ ObjectDefineProperties(AbortSignal.prototype, {
5557
aborted: { enumerable: true }
5658
});
5759

60+
ObjectDefineProperty(AbortSignal.prototype, SymbolToStringTag, {
61+
writable: false,
62+
enumerable: false,
63+
configurable: true,
64+
value: 'AbortSignal',
65+
});
66+
5867
defineEventHandler(AbortSignal.prototype, 'abort');
5968

6069
function createAbortSignal() {
@@ -98,6 +107,13 @@ ObjectDefineProperties(AbortController.prototype, {
98107
abort: { enumerable: true }
99108
});
100109

110+
ObjectDefineProperty(AbortController.prototype, SymbolToStringTag, {
111+
writable: false,
112+
enumerable: false,
113+
configurable: true,
114+
value: 'AbortController',
115+
});
116+
101117
module.exports = {
102118
AbortController,
103119
AbortSignal,
Collapse file

‎test/parallel/test-abortcontroller.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-abortcontroller.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ const { ok, strictEqual, throws } = require('assert');
6060
/^TypeError: Illegal constructor$/
6161
);
6262
}
63+
{
64+
// Symbol.toStringTag
65+
const toString = (o) => Object.prototype.toString.call(o);
66+
const ac = new AbortController();
67+
strictEqual(toString(ac), '[object AbortController]');
68+
strictEqual(toString(ac.signal), '[object AbortSignal]');
69+
}
Collapse file

‎test/parallel/test-eventtarget-memoryleakwarning.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eventtarget-memoryleakwarning.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ common.expectWarning({
2121
'Use events.setMaxListeners() to increase ' +
2222
'limit'],
2323
['Possible EventTarget memory leak detected. 3 foo listeners added to ' +
24-
'[AbortSignal [EventTarget]]. ' +
24+
'[AbortSignal]. ' +
2525
'Use events.setMaxListeners() to increase ' +
2626
'limit'],
2727
],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.