Skip to content

Commit fcd8bdd

Browse files
authored
chore: remove EventTarget from the isAbortSignal (node-fetch#1490)
BREAKING CHANGE: when checking if something is a AbortSignal we no longer check if name match EventTarget
1 parent 1c775f1 commit fcd8bdd

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/utils/is.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,7 @@ export const isBlob = object => {
4949
* @return {boolean}
5050
*/
5151
export const isAbortSignal = object => {
52-
return (
53-
typeof object === 'object' && (
54-
object[NAME] === 'AbortSignal' ||
55-
object[NAME] === 'EventTarget'
56-
)
57-
);
52+
return object?.[NAME] === 'AbortSignal';
5853
};
5954

6055
/**

test/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,11 +1206,11 @@ describe('node-fetch', () => {
12061206

12071207
testAbortController('mysticatea', () => new AbortControllerMysticatea());
12081208

1209-
if (process.version > 'v15') {
1210-
testAbortController('native', () => new AbortController());
1209+
if (globalThis.AbortController) {
1210+
testAbortController('native', () => new globalThis.AbortController());
12111211
}
12121212

1213-
it('should throw a TypeError if a signal is not of type AbortSignal or EventTarget', () => {
1213+
it('should throw a TypeError if a signal is not of type AbortSignal', () => {
12141214
return Promise.all([
12151215
expect(fetch(`${base}inspect`, {signal: {}}))
12161216
.to.be.eventually.rejected

0 commit comments

Comments
 (0)