From a5ec7fc2518b43932c88807da5e9e038acd5e6ba Mon Sep 17 00:00:00 2001 From: James Woglom Date: Tue, 27 Feb 2024 07:17:29 -0500 Subject: [PATCH] Resolve iframe CORS errors - Fix #19724 (#19884) * Resolve iframe CORS errors - Fix #19724 * add newline --- src/common/dom/get_main_window.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common/dom/get_main_window.ts b/src/common/dom/get_main_window.ts index a2a5cca7b1..0f727eb244 100644 --- a/src/common/dom/get_main_window.ts +++ b/src/common/dom/get_main_window.ts @@ -1,8 +1,13 @@ import { MAIN_WINDOW_NAME } from "../../data/main_window"; -export const mainWindow = - window.name === MAIN_WINDOW_NAME - ? window - : parent.name === MAIN_WINDOW_NAME - ? parent - : top!; +export const mainWindow = (() => { + try { + return window.name === MAIN_WINDOW_NAME + ? window + : parent.name === MAIN_WINDOW_NAME + ? parent + : top!; + } catch { + return window; + } +})();