From 7c76563056b16b7fc7c326595614b2989fcfab6e Mon Sep 17 00:00:00 2001 From: Clay Miller Date: Wed, 14 Jan 2026 15:57:38 -0500 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20Make=20the=20polyfill=20SSR-safe=20(?= =?UTF-8?q?early-return=20when=20Element=20or=20Document=20doesn=E2=80=99t?= =?UTF-8?q?=20exist)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arianotify-polyfill.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arianotify-polyfill.js b/arianotify-polyfill.js index 7f3182b..c3ff76c 100644 --- a/arianotify-polyfill.js +++ b/arianotify-polyfill.js @@ -1,6 +1,6 @@ // @ts-check -if (!("ariaNotify" in Element.prototype) || !("ariaNotify" in Document.prototype)) { +if (typeof globalThis.Element !== "undefined" && typeof globalThis.Document !== "undefined" && (!("ariaNotify" in Element.prototype) || !("ariaNotify" in Document.prototype))) { /** @type {string} */ let uniqueId = `${Date.now()}`; try { From 26d7092863d9c6223fcafba995bb869bc12ee5ca Mon Sep 17 00:00:00 2001 From: Clay Miller Date: Wed, 14 Jan 2026 16:03:02 -0500 Subject: [PATCH 2/2] fix: Improve readability --- arianotify-polyfill.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arianotify-polyfill.js b/arianotify-polyfill.js index c3ff76c..b3b079e 100644 --- a/arianotify-polyfill.js +++ b/arianotify-polyfill.js @@ -1,6 +1,13 @@ // @ts-check -if (typeof globalThis.Element !== "undefined" && typeof globalThis.Document !== "undefined" && (!("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 (typeof globalThis.Element !== "undefined" && typeof globalThis.Document !== queue.enqueue(new Message({ element: this.documentElement, message, priority })); }; } -} +} \ No newline at end of file