@@ -16,7 +16,7 @@ import { warn } from '../warning'
16
16
import { isKeepAlive } from './KeepAlive'
17
17
import { toRaw } from '@vue/reactivity'
18
18
import { ErrorCodes , callWithAsyncErrorHandling } from '../errorHandling'
19
- import { PatchFlags , ShapeFlags , isArray } from '@vue/shared'
19
+ import { PatchFlags , ShapeFlags , isArray , isFunction } from '@vue/shared'
20
20
import { onBeforeUnmount , onMounted } from '../apiLifecycle'
21
21
import type { RendererElement } from '../renderer'
22
22
@@ -459,15 +459,27 @@ function emptyPlaceholder(vnode: VNode): VNode | undefined {
459
459
}
460
460
461
461
function getKeepAliveChild ( vnode : VNode ) : VNode | undefined {
462
- return isKeepAlive ( vnode )
463
- ? // #7121 ensure get the child component subtree in case
464
- // it's been replaced during HMR
465
- __DEV__ && vnode . component
466
- ? vnode . component . subTree
467
- : vnode . children
468
- ? ( ( vnode . children as VNodeArrayChildren ) [ 0 ] as VNode )
469
- : undefined
470
- : 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
+ const { shapeFlag, children } = vnode
472
+
473
+ if ( shapeFlag & ShapeFlags . ARRAY_CHILDREN ) {
474
+ return ( children as VNodeArrayChildren ) [ 0 ] as VNode
Has a conversation. Original line has a conversation.
475
+ }
476
+
477
+ if (
478
+ shapeFlag & ShapeFlags . SLOTS_CHILDREN &&
479
+ isFunction ( ( children as any ) . default )
480
+ ) {
481
+ return ( children as any ) . default ( )
482
+ }
471
483
}
472
484
473
485
export function setTransitionHooks ( vnode : VNode , hooks : TransitionHooks ) {