From 2874ac9cabb6ad8629b23e1eb64c9804578a95be Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Mon, 10 Jun 2024 14:26:46 -0400 Subject: [PATCH] Use `globalThis`. It's designed to solve exactly this problem, and has been universally available since 2020. The most likely scenario for `globalThis` to fail is if the user is stuck with an old browser, in which case `self` will be available. `window` will be too, but `self` also works in web workers. --- templates/html5/output.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/html5/output.js b/templates/html5/output.js index 421abf2ad..46889eae2 100644 --- a/templates/html5/output.js +++ b/templates/html5/output.js @@ -35,8 +35,8 @@ define.__amd = define.amd; define.amd = null; } -})(typeof exports !== "undefined" ? exports : typeof define === "function" && define.amd ? {} : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : this, - typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : this); +})(typeof exports !== "undefined" ? exports : typeof define === "function" && define.amd ? {} : typeof globalThis !== "undefined" ? globalThis : self, + typeof globalThis !== "undefined" ? globalThis : self); ::if embeddedLibraries::::foreach embeddedLibraries:: ::__current__::::end::::end::