From c1454bc7b5683b5aa495db2a9ae6a7c5494ee08c Mon Sep 17 00:00:00 2001 From: huiliangShen Date: Sat, 11 Nov 2023 09:28:33 +0800 Subject: [PATCH] fix(carousel): can not use jsx render children (#7077) Co-authored-by: banruo --- components/_util/vnode.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/_util/vnode.ts b/components/_util/vnode.ts index 505bb638d..1f8265c2d 100644 --- a/components/_util/vnode.ts +++ b/components/_util/vnode.ts @@ -1,6 +1,6 @@ import { filterEmpty } from './props-util'; import type { VNode, VNodeProps } from 'vue'; -import { cloneVNode } from 'vue'; +import { cloneVNode, isVNode } from 'vue'; import warning from './warning'; import type { RefObject } from './createRef'; type NodeProps = Record & @@ -40,6 +40,10 @@ export function deepCloneElement( if (Array.isArray(vnode)) { return vnode.map(item => deepCloneElement(item, nodeProps, override, mergeRef)); } else { + // 需要判断是否为vnode方可进行clone操作 + if (!isVNode(vnode)) { + return vnode; + } const cloned = cloneElement(vnode, nodeProps, override, mergeRef); if (Array.isArray(cloned.children)) { cloned.children = deepCloneElement(cloned.children as VNode[]);