fix(angular): Fix cordova browser error when resumed (#16810)

* fix cordova resume error

In cordova browser error is thrown everytime tab/window is reactivated:
Uncaught TypeError: Cannot read property 'detail' of undefined
    at Channel.<anonymous> (util.js:10)
    at Channel.fire (cordova.js:798)
    at HTMLDocument.<anonymous> (cordova.js:1511)

That was fixed in previous commits, by in latest was reintroduced again.

* update types
This commit is contained in:
Mark Levy
2018-12-19 13:35:28 +01:00
committed by Manu MA
parent fb380028ee
commit e735d2cbd1

View File

@ -10,8 +10,9 @@ export function inputs(instance: any, el: ElementRef, props: string[]) {
}
export function proxyEvent<T>(emitter: Subject<T>, el: EventTarget, eventName: string) {
el.addEventListener(eventName, ev => {
emitter.next((ev as any).detail as T);
el.addEventListener(eventName, (ev: Event | undefined | null) => {
// ?? cordova might emit "null" events
emitter.next(ev != null ? (ev as any).detail as T : undefined);
});
}