From b934598e93a3a0fd85fb16961c22acd96527f5c3 Mon Sep 17 00:00:00 2001 From: Bradley Maier Date: Tue, 30 Jul 2019 12:53:22 -0400 Subject: [PATCH 1/2] Add jsdom user agent check to global shim --- src/shim/global.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shim/global.ts b/src/shim/global.ts index 1731fd18f..d8dc44ff5 100644 --- a/src/shim/global.ts +++ b/src/shim/global.ts @@ -2,6 +2,9 @@ const globalObject: any = (function(): any { // the only reliable means to get the global object is // `Function('return this')()` // However, this causes CSP violations in Chrome apps. + if (typeof window !== 'undefined' && window.navigator.userAgent.includes('jsdom')) { + return window; + } if (typeof globalThis !== 'undefined') { return globalThis; } From a8629d9acb3f54d5365bb1d52997babe7a9f838d Mon Sep 17 00:00:00 2001 From: Bradley Maier Date: Tue, 30 Jul 2019 13:28:27 -0400 Subject: [PATCH 2/2] Use indexOf instead of includes --- src/shim/global.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shim/global.ts b/src/shim/global.ts index d8dc44ff5..d1e5c3d14 100644 --- a/src/shim/global.ts +++ b/src/shim/global.ts @@ -2,7 +2,7 @@ const globalObject: any = (function(): any { // the only reliable means to get the global object is // `Function('return this')()` // However, this causes CSP violations in Chrome apps. - if (typeof window !== 'undefined' && window.navigator.userAgent.includes('jsdom')) { + if (typeof window !== 'undefined' && window.navigator.userAgent.indexOf('jsdom') > -1) { return window; } if (typeof globalThis !== 'undefined') {