|
|
@@ -624,10 +624,11 @@ export function cloneVNode<T, U>(
|
|
|
vnode: VNode<T, U>,
|
|
|
extraProps?: (Data & VNodeProps) | null,
|
|
|
mergeRef = false,
|
|
|
+ cloneTransition = false,
|
|
|
): VNode<T, U> {
|
|
|
// This is intentionally NOT using spread or extend to avoid the runtime
|
|
|
// key enumeration cost.
|
|
|
- const { props, ref, patchFlag, children } = vnode
|
|
|
+ const { props, ref, patchFlag, children, transition } = vnode
|
|
|
const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props
|
|
|
const cloned: VNode<T, U> = {
|
|
|
__v_isVNode: true,
|
|
|
@@ -670,7 +671,7 @@ export function cloneVNode<T, U>(
|
|
|
dynamicChildren: vnode.dynamicChildren,
|
|
|
appContext: vnode.appContext,
|
|
|
dirs: vnode.dirs,
|
|
|
- transition: vnode.transition,
|
|
|
+ transition,
|
|
|
|
|
|
// These should technically only be non-null on mounted VNodes. However,
|
|
|
// they *should* be copied for kept-alive vnodes. So we just always copy
|
|
|
@@ -685,9 +686,18 @@ export function cloneVNode<T, U>(
|
|
|
ctx: vnode.ctx,
|
|
|
ce: vnode.ce,
|
|
|
}
|
|
|
+
|
|
|
+ // if the vnode will be replaced by the cloned one, it is necessary
|
|
|
+ // to clone the transition to ensure that the vnode referenced within
|
|
|
+ // the transition hooks is fresh.
|
|
|
+ if (transition && cloneTransition) {
|
|
|
+ cloned.transition = transition.clone(cloned as VNode)
|
|
|
+ }
|
|
|
+
|
|
|
if (__COMPAT__) {
|
|
|
defineLegacyVNodeProperties(cloned as VNode)
|
|
|
}
|
|
|
+
|
|
|
return cloned
|
|
|
}
|
|
|
|