From 3724693a25c3f2dd13d70a8a1af760b03a4fb783 Mon Sep 17 00:00:00 2001 From: edison Date: Wed, 24 Apr 2024 16:32:39 +0800 Subject: [PATCH] fix(runtime-core): properly get keepAlive child (#10772) close #10771 --- .../src/components/BaseTransition.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index 5d41751285b..8fa272d2613 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -470,15 +470,17 @@ function getKeepAliveChild(vnode: VNode): VNode | undefined { const { shapeFlag, children } = vnode - if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) { - return (children as VNodeArrayChildren)[0] as VNode - } + if (children) { + if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) { + return (children as VNodeArrayChildren)[0] as VNode + } - if ( - shapeFlag & ShapeFlags.SLOTS_CHILDREN && - isFunction((children as any).default) - ) { - return (children as any).default() + if ( + shapeFlag & ShapeFlags.SLOTS_CHILDREN && + isFunction((children as any).default) + ) { + return (children as any).default() + } } }