From 76b75fae36d46a6dba9db41a74161efe0ed41d55 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 6 Nov 2023 16:54:39 +0000 Subject: [PATCH] DEV: Simplify I18n shim check (#24244) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have identified some third-party analytics scripts which do things like `window.I18n = window.I18n` 🤦‍♂️. This leads to the window object having a null I18n property, but `"I18n" in globalThis` returns true. This commit checks whether `window.I18n` is a truthy value. --- app/assets/javascripts/discourse-i18n/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse-i18n/src/index.js b/app/assets/javascripts/discourse-i18n/src/index.js index 26b5e4ccd61..650836ff59d 100644 --- a/app/assets/javascripts/discourse-i18n/src/index.js +++ b/app/assets/javascripts/discourse-i18n/src/index.js @@ -1,4 +1,4 @@ -if ("I18n" in globalThis) { +if (window.I18n) { throw new Error( "I18n already defined, discourse-i18n unexpectedly loaded twice!" );