@@ -134,7 +134,21 @@ const isPromisey = (maybePromise: Promise<void> | unknown): maybePromise is Prom
134134 maybePromise instanceof Promise ||
135135 ( maybePromise && ( maybePromise as any ) . then && typeof ( maybePromise as Promise < void > ) . then === 'function' ) ;
136136
137- const updateComponent = async ( hostRef : d . HostRef , instance : any , isInitialLoad : boolean ) => {
137+ /**
138+ * Update a component given reference to its host elements and so on.
139+ *
140+ * @param hostRef an object containing references to the element's host node,
141+ * VDom nodes, and other metadata
142+ * @param instance a reference to the underlying host element where it will be
143+ * rendered
144+ * @param isInitialLoad whether or not this function is being called as part of
145+ * the first render cycle
146+ */
147+ const updateComponent = async (
148+ hostRef : d . HostRef ,
149+ instance : d . HostElement | d . ComponentInterface ,
150+ isInitialLoad : boolean ,
151+ ) => {
138152 const elm = hostRef . $hostElement$ as d . RenderNode ;
139153 const endUpdate = createTime ( 'update' , hostRef . $cmpMeta$ . $tagName$ ) ;
140154 const rc = elm [ 's-rc' ] ;
@@ -149,9 +163,9 @@ const updateComponent = async (hostRef: d.HostRef, instance: any, isInitialLoad:
149163 }
150164
151165 if ( BUILD . hydrateServerSide ) {
152- await callRender ( hostRef , instance , elm ) ;
166+ await callRender ( hostRef , instance , elm , isInitialLoad ) ;
153167 } else {
154- callRender ( hostRef , instance , elm ) ;
168+ callRender ( hostRef , instance , elm , isInitialLoad ) ;
155169 }
156170
157171 if ( BUILD . isDev ) {
@@ -205,7 +219,19 @@ const updateComponent = async (hostRef: d.HostRef, instance: any, isInitialLoad:
205219
206220let renderingRef : any = null ;
207221
208- const callRender = ( hostRef : d . HostRef , instance : any , elm : HTMLElement ) => {
222+ /**
223+ * Handle making the call to the VDom renderer with the proper context given
224+ * various build variables
225+ *
226+ * @param hostRef an object containing references to the element's host node,
227+ * VDom nodes, and other metadata
228+ * @param instance a reference to the underlying host element where it will be
229+ * rendered
230+ * @param elm the Host element for the component
231+ * @param isInitialLoad whether or not this function is being called as part of
232+ * @returns an empty promise
233+ */
234+ const callRender = ( hostRef : d . HostRef , instance : any , elm : HTMLElement , isInitialLoad : boolean ) => {
209235 // in order for bundlers to correctly treeshake the BUILD object
210236 // we need to ensure BUILD is not deoptimized within a try/catch
211237 // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
@@ -231,9 +257,9 @@ const callRender = (hostRef: d.HostRef, instance: any, elm: HTMLElement) => {
231257 // or we need to update the css class/attrs on the host element
232258 // DOM WRITE!
233259 if ( BUILD . hydrateServerSide ) {
234- return Promise . resolve ( instance ) . then ( ( value ) => renderVdom ( hostRef , value ) ) ;
260+ return Promise . resolve ( instance ) . then ( ( value ) => renderVdom ( hostRef , value , isInitialLoad ) ) ;
235261 } else {
236- renderVdom ( hostRef , instance ) ;
262+ renderVdom ( hostRef , instance , isInitialLoad ) ;
237263 }
238264 } else {
239265 elm . textContent = instance ;
0 commit comments