From fce1136b14244e0eb6593d4eafe254ff82d06133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2=20=D0=98=D0=B3=D0=BE?= =?UTF-8?q?=D1=80=D1=8C?= Date: Sat, 4 Apr 2020 12:55:49 +0300 Subject: [PATCH 1/2] feat(internal): Support globalThis in modern environments fix #3561 --- src/runtime/internal/globals.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/internal/globals.ts b/src/runtime/internal/globals.ts index 664093d2e4fd..831555163ffa 100644 --- a/src/runtime/internal/globals.ts +++ b/src/runtime/internal/globals.ts @@ -1,3 +1,7 @@ declare const global: any; -export const globals = (typeof window !== 'undefined' ? window : global) as unknown as typeof globalThis; +export const globals = (typeof globalThis !== 'undefined' + ? globalThis + : typeof window !== 'undefined' + ? window + : global) as unknown as typeof globalThis; From 75055361fd9ddcfd80bfba040b5e699a8ddb6747 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 6 Apr 2020 06:48:16 -0400 Subject: [PATCH 2/2] check for presence of `window` first --- src/runtime/internal/globals.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/internal/globals.ts b/src/runtime/internal/globals.ts index 831555163ffa..b97f81ab9f47 100644 --- a/src/runtime/internal/globals.ts +++ b/src/runtime/internal/globals.ts @@ -1,7 +1,7 @@ declare const global: any; -export const globals = (typeof globalThis !== 'undefined' - ? globalThis - : typeof window !== 'undefined' +export const globals = (typeof window !== 'undefined' ? window + : typeof globalThis !== 'undefined' + ? globalThis : global) as unknown as typeof globalThis;