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; + } +})();