|
1 | 1 | import type * as d from '../declarations'; |
2 | 2 | import { BUILD } from '@app-data'; |
3 | | -import { doc, plt, supportsListenerOptions, win } from '@platform'; |
| 3 | +import { doc, plt, consoleError, supportsListenerOptions, win } from '@platform'; |
4 | 4 | import { HOST_FLAGS, LISTENER_FLAGS } from '@utils'; |
5 | 5 |
|
6 | 6 | export const addHostEventListeners = (elm: d.HostElement, hostRef: d.HostRef, listeners: d.ComponentRuntimeHostListener[], attachParentListeners: boolean) => { |
@@ -36,15 +36,19 @@ export const addHostEventListeners = (elm: d.HostElement, hostRef: d.HostRef, li |
36 | 36 | }; |
37 | 37 |
|
38 | 38 | const hostListenerProxy = (hostRef: d.HostRef, methodName: string) => (ev: Event) => { |
39 | | - if (BUILD.lazyLoad) { |
40 | | - if (hostRef.$flags$ & HOST_FLAGS.isListenReady) { |
41 | | - // instance is ready, let's call it's member method for this event |
42 | | - hostRef.$lazyInstance$[methodName](ev); |
| 39 | + try { |
| 40 | + if (BUILD.lazyLoad) { |
| 41 | + if (hostRef.$flags$ & HOST_FLAGS.isListenReady) { |
| 42 | + // instance is ready, let's call it's member method for this event |
| 43 | + hostRef.$lazyInstance$[methodName](ev); |
| 44 | + } else { |
| 45 | + (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]); |
| 46 | + } |
43 | 47 | } else { |
44 | | - (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]); |
| 48 | + (hostRef.$hostElement$ as any)[methodName](ev); |
45 | 49 | } |
46 | | - } else { |
47 | | - (hostRef.$hostElement$ as any)[methodName](ev); |
| 50 | + } catch (e) { |
| 51 | + consoleError(e); |
48 | 52 | } |
49 | 53 | }; |
50 | 54 |
|
|
0 commit comments