mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-04-27 05:10:12 +08:00
fix(ssr): fix window references
This commit is contained in:
parent
5b1bdc37e0
commit
c2029f7927
@ -149,7 +149,11 @@ function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: a
|
|||||||
* @returns {Observable}
|
* @returns {Observable}
|
||||||
*/
|
*/
|
||||||
function wrapEventObservable(event: string, element: any): Observable<any> {
|
function wrapEventObservable(event: string, element: any): Observable<any> {
|
||||||
element = element ? get(window, element) : window;
|
if (typeof window !== 'undefined') {
|
||||||
|
element = element && typeof window !== 'undefined' ? get(window, element) : window;
|
||||||
|
} else {
|
||||||
|
element = element || {};
|
||||||
|
}
|
||||||
return fromEvent(element, event);
|
return fromEvent(element, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +311,10 @@ export function callInstance(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getPlugin(pluginRef: string): any {
|
export function getPlugin(pluginRef: string): any {
|
||||||
return get(window, pluginRef);
|
if (typeof window !== 'undefined') {
|
||||||
|
return get(window, pluginRef);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get(element: Element | Window, path: string) {
|
export function get(element: Element | Window, path: string) {
|
||||||
|
@ -26,7 +26,10 @@ export class IonicNativePlugin {
|
|||||||
* Returns the original plugin object
|
* Returns the original plugin object
|
||||||
*/
|
*/
|
||||||
static getPlugin(): any {
|
static getPlugin(): any {
|
||||||
return get(window, this.pluginRef);
|
if (typeof window !== 'undefined') {
|
||||||
|
return get(window, this.pluginRef);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user