Skip to content

Commit

Permalink
chore: remove EventTarget from the isAbortSignal (#1490)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: when checking if something is a AbortSignal we no longer check if name match EventTarget
  • Loading branch information
jimmywarting committed Jan 27, 2022
1 parent 1c775f1 commit fcd8bdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/utils/is.js
Expand Up @@ -49,12 +49,7 @@ export const isBlob = object => {
* @return {boolean}
*/
export const isAbortSignal = object => {
return (
typeof object === 'object' && (
object[NAME] === 'AbortSignal' ||
object[NAME] === 'EventTarget'
)
);
return object?.[NAME] === 'AbortSignal';
};

/**
Expand Down
6 changes: 3 additions & 3 deletions test/main.js
Expand Up @@ -1206,11 +1206,11 @@ describe('node-fetch', () => {

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

if (process.version > 'v15') {
testAbortController('native', () => new AbortController());
if (globalThis.AbortController) {
testAbortController('native', () => new globalThis.AbortController());
}

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

0 comments on commit fcd8bdd

Please sign in to comment.