@@ -92,7 +92,7 @@ const dispatchHooks = (hostRef: d.HostRef, isInitialLoad: boolean): Promise<void
9292 if ( BUILD . lazyLoad && BUILD . hostListener ) {
9393 hostRef . $flags$ |= HOST_FLAGS . isListenReady ;
9494 if ( hostRef . $queuedListeners$ ) {
95- hostRef . $queuedListeners$ . map ( ( [ methodName , event ] ) => safeCall ( instance , methodName , event ) ) ;
95+ hostRef . $queuedListeners$ . map ( ( [ methodName , event ] ) => safeCall ( instance , methodName , event , elm ) ) ;
9696 hostRef . $queuedListeners$ = undefined ;
9797 }
9898 }
@@ -103,7 +103,7 @@ const dispatchHooks = (hostRef: d.HostRef, isInitialLoad: boolean): Promise<void
103103 // rendering the component, doing other lifecycle stuff, etc. So
104104 // in that case we assign the returned promise to the variable we
105105 // declared above to hold a possible 'queueing' Promise
106- maybePromise = safeCall ( instance , 'componentWillLoad' ) ;
106+ maybePromise = safeCall ( instance , 'componentWillLoad' , undefined , elm ) ;
107107 }
108108 } else {
109109 emitLifecycleEvent ( elm , 'componentWillUpdate' ) ;
@@ -114,13 +114,13 @@ const dispatchHooks = (hostRef: d.HostRef, isInitialLoad: boolean): Promise<void
114114 // we specify that our runtime will wait for that `Promise` to
115115 // resolve before the component re-renders. So if the method
116116 // returns a `Promise` we need to keep it around!
117- maybePromise = safeCall ( instance , 'componentWillUpdate' ) ;
117+ maybePromise = safeCall ( instance , 'componentWillUpdate' , undefined , elm ) ;
118118 }
119119 }
120120
121121 emitLifecycleEvent ( elm , 'componentWillRender' ) ;
122122 if ( BUILD . cmpWillRender ) {
123- maybePromise = enqueue ( maybePromise , ( ) => safeCall ( instance , 'componentWillRender' ) ) ;
123+ maybePromise = enqueue ( maybePromise , ( ) => safeCall ( instance , 'componentWillRender' , undefined , elm ) ) ;
124124 }
125125
126126 endSchedule ( ) ;
@@ -326,7 +326,7 @@ export const postUpdateComponent = (hostRef: d.HostRef) => {
326326 if ( BUILD . isDev ) {
327327 hostRef . $flags$ |= HOST_FLAGS . devOnRender ;
328328 }
329- safeCall ( instance , 'componentDidRender' ) ;
329+ safeCall ( instance , 'componentDidRender' , undefined , elm ) ;
330330 if ( BUILD . isDev ) {
331331 hostRef . $flags$ &= ~ HOST_FLAGS . devOnRender ;
332332 }
@@ -345,7 +345,7 @@ export const postUpdateComponent = (hostRef: d.HostRef) => {
345345 if ( BUILD . isDev ) {
346346 hostRef . $flags$ |= HOST_FLAGS . devOnDidLoad ;
347347 }
348- safeCall ( instance , 'componentDidLoad' ) ;
348+ safeCall ( instance , 'componentDidLoad' , undefined , elm ) ;
349349 if ( BUILD . isDev ) {
350350 hostRef . $flags$ &= ~ HOST_FLAGS . devOnDidLoad ;
351351 }
@@ -369,7 +369,7 @@ export const postUpdateComponent = (hostRef: d.HostRef) => {
369369 if ( BUILD . isDev ) {
370370 hostRef . $flags$ |= HOST_FLAGS . devOnRender ;
371371 }
372- safeCall ( instance , 'componentDidUpdate' ) ;
372+ safeCall ( instance , 'componentDidUpdate' , undefined , elm ) ;
373373 if ( BUILD . isDev ) {
374374 hostRef . $flags$ &= ~ HOST_FLAGS . devOnRender ;
375375 }
@@ -438,14 +438,15 @@ export const appDidLoad = (who: string) => {
438438 * @param instance any object that may or may not contain methods
439439 * @param method method name
440440 * @param arg single arbitrary argument
441+ * @param elm the element which made the call
441442 * @returns result of method call if it exists, otherwise `undefined`
442443 */
443- export const safeCall = ( instance : any , method : string , arg ?: any ) => {
444+ export const safeCall = ( instance : any , method : string , arg ?: any , elm ?: HTMLElement ) => {
444445 if ( instance && instance [ method ] ) {
445446 try {
446447 return instance [ method ] ( arg ) ;
447448 } catch ( e ) {
448- consoleError ( e ) ;
449+ consoleError ( e , elm ) ;
449450 }
450451 }
451452 return undefined ;
0 commit comments