diff --git a/arianotify-polyfill.js b/arianotify-polyfill.js index 7f3182b..b3b079e 100644 --- a/arianotify-polyfill.js +++ b/arianotify-polyfill.js @@ -1,6 +1,13 @@ // @ts-check -if (!("ariaNotify" in Element.prototype) || !("ariaNotify" in Document.prototype)) { +const domAPIsAreAvailable = + typeof globalThis.Element !== "undefined" && + typeof globalThis.Document !== "undefined"; + +if ( + domAPIsAreAvailable && + (!("ariaNotify" in Element.prototype) || !("ariaNotify" in Document.prototype)) +) { /** @type {string} */ let uniqueId = `${Date.now()}`; try { @@ -193,4 +200,4 @@ if (!("ariaNotify" in Element.prototype) || !("ariaNotify" in Document.prototype queue.enqueue(new Message({ element: this.documentElement, message, priority })); }; } -} +} \ No newline at end of file