From: edison Date: Wed, 24 Apr 2024 08:32:39 +0000 (+0800) Subject: fix(runtime-core): properly get keepAlive child (#10772) X-Git-Tag: v3.4.25~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3724693a25c3f2dd13d70a8a1af760b03a4fb783;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-core): properly get keepAlive child (#10772) close #10771 --- diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index 5d41751285..8fa272d261 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() + } } }