]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): properly get keepAlive child (#10772)
authoredison <daiwei521@126.com>
Wed, 24 Apr 2024 08:32:39 +0000 (16:32 +0800)
committerGitHub <noreply@github.com>
Wed, 24 Apr 2024 08:32:39 +0000 (16:32 +0800)
close #10771

packages/runtime-core/src/components/BaseTransition.ts

index 5d41751285bf5c6ee7fbd0a0b2e02d51e31f25a2..8fa272d2613e11a96cf9c3b5ea3267c5a28e1452 100644 (file)
@@ -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()
+    }
   }
 }