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.
This commit is contained in:
Domvel 2019-09-13 14:38:01 +02:00 committed by Daniel Sogl
parent 2b347fe889
commit 8b3b2a4b27

View File

@ -149,7 +149,7 @@ function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: a
* @returns {Observable}
*/
function wrapEventObservable(event: string, element: any): Observable<any> {
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);
}