From 10e00a99a4bc0e726b0eb8935452a2ed19194d29 Mon Sep 17 00:00:00 2001 From: Martin Olsson Date: Sat, 8 Oct 2022 11:33:27 +0200 Subject: [PATCH] Quickfix to avoid DOMException constructor (not available on MSIE 11) --- src/abortcontroller.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/abortcontroller.js b/src/abortcontroller.js index 13f4b6f..c470bb7 100644 --- a/src/abortcontroller.js +++ b/src/abortcontroller.js @@ -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() {