Skip to content

Commit

Permalink
Quickfix to avoid DOMException constructor (not available on MSIE 11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mo committed Oct 8, 2022
1 parent 8eb3ee5 commit 10e00a9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/abortcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,18 @@ export class AbortController {
signalReason = new Error('This operation was aborted');
signalReason.name = 'AbortError';
} else {
signalReason = new DOMException('signal is aborted without reason');
try {
signalReason = new DOMException('signal is aborted without reason');
} catch (err) {
// IE 11 does not support calling the DOMException constructor, use a
// regular error object on it instead.
signalReason = new Error('This operation was aborted');
signalReason.name = 'AbortError';
}
}
}
this.signal.reason = signalReason;

this.signal.dispatchEvent(event);
}
toString() {
Expand Down

0 comments on commit 10e00a9

Please sign in to comment.