From 8b3b2a4b277599dd9d74dc961daf686bb1c895a5 Mon Sep 17 00:00:00 2001 From: Domvel <35452565+Domvel@users.noreply.github.com> Date: Fri, 13 Sep 2019 14:38:01 +0200 Subject: [PATCH] fix(core): Return the window object as default instead of the boolean from the typeof comparison (#3160) * Fixes #2972 https://github.com/ionic-team/ionic-native/issues/2972 * If window does not exist. But is there a case where window does not exist? If ionic-native always runs in browsers enviroment (like Cordova / WebView) we could remove the `typeof` checks. --- src/@ionic-native/core/decorators/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/@ionic-native/core/decorators/common.ts b/src/@ionic-native/core/decorators/common.ts index a89e7b6fa..af6833f59 100644 --- a/src/@ionic-native/core/decorators/common.ts +++ b/src/@ionic-native/core/decorators/common.ts @@ -149,7 +149,7 @@ function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: a * @returns {Observable} */ function wrapEventObservable(event: string, element: any): Observable { - element = (typeof window !== 'undefined' && element) ? get(window, element) : element || typeof window !== 'undefined' || {}; + element = (typeof window !== 'undefined' && element) ? get(window, element) : element || (typeof window !== 'undefined' ? window : {}); return fromEvent(element, event); }