From c44ad701a782454a1bd771075419d74490175301 Mon Sep 17 00:00:00 2001 From: Florian Gyger Date: Thu, 30 Apr 2020 08:02:30 +0000 Subject: [PATCH 1/3] fix(web): Check if in browser before using window variable --- core/src/web-runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/web-runtime.ts b/core/src/web-runtime.ts index 7c6776762..61484ea85 100644 --- a/core/src/web-runtime.ts +++ b/core/src/web-runtime.ts @@ -13,7 +13,7 @@ export class CapacitorWeb { // Gracefully degrade in non-Proxy supporting engines, e.g. IE11. This // effectively means that trying to access an unavailable plugin will // locally throw, but this is still better than throwing a syntax error. - if ('Proxy' in window) { + if (typeof window !== 'undefined' && 'Proxy' in window) { // Build a proxy for the Plugins object that returns the "Noop Plugin" // if a plugin isn't available this.Plugins = new Proxy(this.Plugins, { From ad38b468345825d5291298b88cf93b68516f6d55 Mon Sep 17 00:00:00 2001 From: Florian Gyger Date: Thu, 30 Apr 2020 13:55:53 +0000 Subject: [PATCH 2/3] check global for proxy on servers --- core/src/web-runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/web-runtime.ts b/core/src/web-runtime.ts index 61484ea85..d237e62d9 100644 --- a/core/src/web-runtime.ts +++ b/core/src/web-runtime.ts @@ -13,7 +13,7 @@ export class CapacitorWeb { // Gracefully degrade in non-Proxy supporting engines, e.g. IE11. This // effectively means that trying to access an unavailable plugin will // locally throw, but this is still better than throwing a syntax error. - if (typeof window !== 'undefined' && 'Proxy' in window) { + if ('Proxy' in (typeof window === 'undefined' ? global : window)) { // Build a proxy for the Plugins object that returns the "Noop Plugin" // if a plugin isn't available this.Plugins = new Proxy(this.Plugins, { From a7601e657dfe2c66e1def6f510b883e5aa027e3b Mon Sep 17 00:00:00 2001 From: Florian Gyger Date: Tue, 19 May 2020 07:58:05 +0200 Subject: [PATCH 3/3] simplified code Co-authored-by: dwieeb --- core/src/web-runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/web-runtime.ts b/core/src/web-runtime.ts index d237e62d9..ee4edc874 100644 --- a/core/src/web-runtime.ts +++ b/core/src/web-runtime.ts @@ -13,7 +13,7 @@ export class CapacitorWeb { // Gracefully degrade in non-Proxy supporting engines, e.g. IE11. This // effectively means that trying to access an unavailable plugin will // locally throw, but this is still better than throwing a syntax error. - if ('Proxy' in (typeof window === 'undefined' ? global : window)) { + if (typeof Proxy !== 'undefined') { // Build a proxy for the Plugins object that returns the "Noop Plugin" // if a plugin isn't available this.Plugins = new Proxy(this.Plugins, {