2020/* eslint-disable simple-import-sort/imports */
2121/* eslint-disable @typescript-eslint/consistent-type-imports */
2222import {
23- _CI , _HI , _M , _MCCC , _ME , _MFCC , _MP , _MR , EMPTY_OBJ , render , VNode , _RFC as renderFunctionalComponent ,
23+ _CI , _HI , _M , _MCCC , _ME , _MFCC , _MP , _MR , EMPTY_OBJ , render , VNode , _RFC as renderFunctionalComponent , AnimationQueues ,
2424} from 'inferno' ;
2525import {
2626 isFunction , isInvalid , isNull , isNullOrUndef , throwError ,
@@ -63,7 +63,7 @@ function isSamePropsInnerHTML(dom: Element, props: any): boolean {
6363 return Boolean ( props && props . dangerouslySetInnerHTML && props . dangerouslySetInnerHTML . __html && isSameInnerHTML ( dom , props . dangerouslySetInnerHTML . __html ) ) ;
6464}
6565
66- function hydrateComponent ( vNode : VNode , parentDOM : Element , dom : Element , context : any , isSVG : boolean , isClass : boolean , lifecycle : Function [ ] ) {
66+ function hydrateComponent ( vNode : VNode , parentDOM : Element , dom : Element , context : any , isSVG : boolean , isClass : boolean , lifecycle : ( ( ) => void ) [ ] , animations : AnimationQueues ) {
6767 const type = vNode . type as Function ;
6868 const ref = vNode . ref ;
6969 const props = vNode . props || EMPTY_OBJ ;
@@ -73,19 +73,19 @@ function hydrateComponent(vNode: VNode, parentDOM: Element, dom: Element, contex
7373 const instance = _CI ( vNode , type , props , context , isSVG , lifecycle ) ;
7474 const input = instance . $LI ;
7575
76- currentNode = hydrateVNode ( input , parentDOM , dom , instance . $CX , isSVG , lifecycle ) ;
77- _MCCC ( ref , instance , lifecycle ) ;
76+ currentNode = hydrateVNode ( input , parentDOM , dom , instance . $CX , isSVG , lifecycle , animations ) ;
77+ _MCCC ( ref , instance , lifecycle , animations ) ;
7878 } else {
7979 const input = _HI ( renderFunctionalComponent ( vNode , context ) ) ;
80- currentNode = hydrateVNode ( input , parentDOM , dom , context , isSVG , lifecycle ) ;
80+ currentNode = hydrateVNode ( input , parentDOM , dom , context , isSVG , lifecycle , animations ) ;
8181 vNode . children = input ;
82- _MFCC ( vNode , lifecycle ) ;
82+ _MFCC ( vNode , lifecycle , animations ) ;
8383 }
8484
8585 return currentNode ;
8686}
8787
88- function hydrateChildren ( parentVNode : VNode , parentNode : any , currentNode : any , context : any , isSVG : boolean , lifecycle : Function [ ] ) {
88+ function hydrateChildren ( parentVNode : VNode , parentNode : any , currentNode : any , context : any , isSVG : boolean , lifecycle : ( ( ) => void ) [ ] , animations : AnimationQueues ) {
8989 const childFlags = parentVNode . childFlags as unknown as ChildFlags ;
9090 const children = parentVNode . children ;
9191 const props = parentVNode . props ;
@@ -94,9 +94,9 @@ function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any,
9494 if ( childFlags !== ChildFlags . HasInvalidChildren ) {
9595 if ( childFlags === ChildFlags . HasVNodeChildren ) {
9696 if ( isNull ( currentNode ) ) {
97- _M ( children as VNode , parentNode , context , isSVG , null , lifecycle ) ;
97+ _M ( children as VNode , parentNode , context , isSVG , null , lifecycle , animations ) ;
9898 } else {
99- currentNode = hydrateVNode ( children as VNode , parentNode , currentNode as Element , context , isSVG , lifecycle ) ;
99+ currentNode = hydrateVNode ( children as VNode , parentNode , currentNode as Element , context , isSVG , lifecycle , animations ) ;
100100 currentNode = currentNode ? currentNode . nextSibling : null ;
101101 }
102102 } else if ( childFlags === ChildFlags . HasTextChildren ) {
@@ -115,9 +115,9 @@ function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any,
115115 const child = ( children as VNode [ ] ) [ i ] ;
116116
117117 if ( isNull ( currentNode ) || ( prevVNodeIsTextNode && ( child . flags & VNodeFlags . Text ) > 0 ) ) {
118- _M ( child as VNode , parentNode , context , isSVG , currentNode , lifecycle ) ;
118+ _M ( child as VNode , parentNode , context , isSVG , currentNode , lifecycle , animations ) ;
119119 } else {
120- currentNode = hydrateVNode ( child as VNode , parentNode , currentNode as Element , context , isSVG , lifecycle ) ;
120+ currentNode = hydrateVNode ( child as VNode , parentNode , currentNode as Element , context , isSVG , lifecycle , animations ) ;
121121 currentNode = currentNode ? currentNode . nextSibling : null ;
122122 }
123123
@@ -144,23 +144,23 @@ function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any,
144144 }
145145}
146146
147- function hydrateElement ( vNode : VNode , parentDOM : Element , dom : Element , context : Object , isSVG : boolean , lifecycle : Function [ ] ) {
147+ function hydrateElement ( vNode : VNode , parentDOM : Element , dom : Element , context , isSVG : boolean , lifecycle : ( ( ) => void ) [ ] , animations : AnimationQueues ) {
148148 const props = vNode . props ;
149149 const className = vNode . className ;
150150 const flags = vNode . flags ;
151151 const ref = vNode . ref ;
152152
153153 isSVG = isSVG || ( flags & VNodeFlags . SvgElement ) > 0 ;
154154 if ( dom . nodeType !== 1 ) {
155- _ME ( vNode , null , context , isSVG , null , lifecycle ) ;
155+ _ME ( vNode , null , context , isSVG , null , lifecycle , animations ) ;
156156 parentDOM . replaceChild ( vNode . dom as Element , dom ) ;
157157 } else {
158158 vNode . dom = dom ;
159159
160- hydrateChildren ( vNode , dom , dom . firstChild , context , isSVG , lifecycle ) ;
160+ hydrateChildren ( vNode , dom , dom . firstChild , context , isSVG , lifecycle , animations ) ;
161161
162162 if ( ! isNull ( props ) ) {
163- _MP ( vNode , flags , props , dom , isSVG ) ;
163+ _MP ( vNode , flags , props , dom , isSVG , animations ) ;
164164 }
165165 if ( isNullOrUndef ( className ) ) {
166166 if ( dom . className !== '' ) {
@@ -192,7 +192,7 @@ function hydrateText(vNode: VNode, parentDOM: Element, dom: Element) {
192192 return vNode . dom ;
193193}
194194
195- function hydrateFragment ( vNode : VNode , parentDOM : Element , dom : Element , context : any , isSVG : boolean , lifecycle : Function [ ] ) : Element {
195+ function hydrateFragment ( vNode : VNode , parentDOM : Element , dom : Element , context : any , isSVG : boolean , lifecycle : ( ( ) => void ) [ ] , animations : AnimationQueues ) : Element {
196196 const children = vNode . children ;
197197
198198 if ( ( vNode . childFlags as unknown as ChildFlags ) === ChildFlags . HasVNodeChildren ) {
@@ -201,19 +201,19 @@ function hydrateFragment(vNode: VNode, parentDOM: Element, dom: Element, context
201201 return ( children as VNode ) . dom as Element ;
202202 }
203203
204- hydrateChildren ( vNode , parentDOM , dom , context , isSVG , lifecycle ) ;
204+ hydrateChildren ( vNode , parentDOM , dom , context , isSVG , lifecycle , animations ) ;
205205
206206 return findLastDOMFromVNode ( ( children as VNode [ ] ) [ ( children as VNode [ ] ) . length - 1 ] ) as Element ;
207207}
208208
209- function hydrateVNode ( vNode : VNode , parentDOM : Element , currentDom : Element , context : Object , isSVG : boolean , lifecycle : Function [ ] ) : Element | null {
209+ function hydrateVNode ( vNode : VNode , parentDOM : Element , currentDom : Element , context : Object , isSVG : boolean , lifecycle : ( ( ) => void ) [ ] , animations : AnimationQueues ) : Element | null {
210210 const flags = ( vNode . flags |= VNodeFlags . InUse ) ;
211211
212212 if ( flags & VNodeFlags . Component ) {
213- return hydrateComponent ( vNode , parentDOM , currentDom , context , isSVG , ( flags & VNodeFlags . ComponentClass ) > 0 , lifecycle ) ;
213+ return hydrateComponent ( vNode , parentDOM , currentDom , context , isSVG , ( flags & VNodeFlags . ComponentClass ) > 0 , lifecycle , animations ) ;
214214 }
215215 if ( flags & VNodeFlags . Element ) {
216- return hydrateElement ( vNode , parentDOM , currentDom , context , isSVG , lifecycle ) ;
216+ return hydrateElement ( vNode , parentDOM , currentDom , context , isSVG , lifecycle , animations ) ;
217217 }
218218 if ( flags & VNodeFlags . Text ) {
219219 return hydrateText ( vNode , parentDOM , currentDom ) ;
@@ -222,24 +222,25 @@ function hydrateVNode(vNode: VNode, parentDOM: Element, currentDom: Element, con
222222 return ( vNode . dom = currentDom ) ;
223223 }
224224 if ( flags & VNodeFlags . Fragment ) {
225- return hydrateFragment ( vNode , parentDOM , currentDom , context , isSVG , lifecycle ) ;
225+ return hydrateFragment ( vNode , parentDOM , currentDom , context , isSVG , lifecycle , animations ) ;
226226 }
227227
228228 throwError ( ) ;
229229
230230 return null ;
231231}
232232
233- export function hydrate ( input : any , parentDOM : Element , callback ?: Function ) {
233+ export function hydrate ( input : any , parentDOM : Element , callback ?: ( ) => void ) {
234234 let dom = parentDOM . firstChild as Element ;
235235
236236 if ( isNull ( dom ) ) {
237237 render ( input , parentDOM , callback ) ;
238238 } else {
239- const lifecycle : Function [ ] = [ ] ;
239+ const lifecycle : ( ( ) => void ) [ ] = [ ] ;
240+ const animations = new AnimationQueues ( ) ;
240241
241242 if ( ! isInvalid ( input ) ) {
242- dom = hydrateVNode ( input , parentDOM , dom , { } , false , lifecycle ) as Element ;
243+ dom = hydrateVNode ( input , parentDOM , dom , { } , false , lifecycle , animations ) as Element ;
243244 }
244245 // clear any other DOM nodes, there should be only a single entry for the root
245246 while ( dom && ( dom = dom . nextSibling as Element ) ) {
0 commit comments