@@ -19,7 +19,6 @@ import { ErrorCodes, callWithAsyncErrorHandling } from '../errorHandling'
1919import { PatchFlags , ShapeFlags , isArray } from '@vue/shared'
2020import { onBeforeUnmount , onMounted } from '../apiLifecycle'
2121import type { RendererElement } from '../renderer'
22- import type { RawSlots , Slot } from '../componentSlots'
2322
2423type Hook < T = ( ) => void > = T | T [ ]
2524
@@ -460,16 +459,24 @@ function emptyPlaceholder(vnode: VNode): VNode | undefined {
460459}
461460
462461function getKeepAliveChild ( vnode : VNode ) : VNode | undefined {
463- return isKeepAlive ( vnode )
464- ? // #7121 ensure get the child component subtree in case
465- // it's been replaced during HMR
466- __DEV__ && vnode . component
467- ? vnode . component . subTree
468- : vnode . children
469- ? ( ( vnode . children as VNodeArrayChildren ) [ 0 ] as VNode ) ||
470- ( ( vnode . children as RawSlots ) . default as Slot ) ?.( )
471- : undefined
472- : vnode
462+ if ( ! isKeepAlive ( vnode ) ) {
463+ return vnode
464+ }
465+ // #7121 ensure get the child component subtree in case
466+ // it's been replaced during HMR
467+ if ( __DEV__ && vnode . component ) {
468+ return vnode . component . subTree
469+ }
470+
471+ if ( vnode . shapeFlag & ShapeFlags . ARRAY_CHILDREN ) {
472+ return ( vnode . children as VNodeArrayChildren ) ?. [ 0 ] as VNode
473+ }
474+
475+ if ( vnode . shapeFlag & ShapeFlags . SLOTS_CHILDREN ) {
476+ return ( vnode . children as any ) ?. default ?.( )
477+ }
478+
479+ return undefined
473480}
474481
475482export function setTransitionHooks ( vnode : VNode , hooks : TransitionHooks ) {
0 commit comments