@@ -399,12 +399,12 @@ export function createComponentWithFallback(
399399export function mountComponent (
400400 instance : VaporComponentInstance ,
401401 parent : ParentNode ,
402- anchor : Node | null | 0 ,
402+ anchor ? : Node | null | 0 ,
403403) : void {
404404 if ( ! instance . isMounted ) {
405405 if ( instance . bm ) invokeArrayFns ( instance . bm )
406406 insert ( instance . block , parent , anchor )
407- // queuePostFlushCb(() => {
407+ // TODO queuePostFlushCb(() => {
408408 if ( instance . m ) invokeArrayFns ( instance . m )
409409 instance . isMounted = true
410410 // })
@@ -415,19 +415,23 @@ export function mountComponent(
415415
416416export function unmountComponent (
417417 instance : VaporComponentInstance ,
418- parent : ParentNode ,
418+ parent ? : ParentNode ,
419419) : void {
420420 if ( instance . isMounted && ! instance . isUnmounted ) {
421421 if ( __DEV__ && instance . type . __hmrId ) {
422422 unregisterHMR ( instance )
423423 }
424424 if ( instance . bum ) invokeArrayFns ( instance . bum )
425425 instance . scope . stop ( )
426- // TODO invoke unmount recursively for children
427- remove ( instance . block , parent )
428- // queuePostFlushCb(() => {
426+ for ( const c of instance . children ) {
427+ unmountComponent ( c )
428+ }
429+ if ( parent ) remove ( instance . block , parent )
430+ // TODO queuePostFlushCb(() => {
429431 if ( instance . um ) invokeArrayFns ( instance . um )
430432 instance . isUnmounted = true
431433 // })
434+ } else if ( parent ) {
435+ remove ( instance . block , parent )
432436 }
433437}
0 commit comments