fix(runtime-core): cloneVNode should preserve correct ctx instance when normalizing ref

fix #1311
This commit is contained in:
Evan You
2020-06-15 15:57:37 -04:00
parent 605953a154
commit be69beed5e
2 changed files with 48 additions and 15 deletions

View File

@@ -277,12 +277,13 @@ export const InternalObjectKey = `__vInternal`
const normalizeKey = ({ key }: VNodeProps): VNode['key'] =>
key != null ? key : null
const normalizeRef = ({ ref }: VNodeProps): VNode['ref'] =>
(ref != null
const normalizeRef = ({ ref }: VNodeProps): VNode['ref'] => {
return (ref != null
? isArray(ref)
? ref
: [currentRenderingInstance!, ref]
: null) as any
}
export const createVNode = (__DEV__
? createVNodeWithArgsTransform
@@ -420,7 +421,7 @@ export function cloneVNode<T, U>(
type: vnode.type,
props,
key: props && normalizeKey(props),
ref: props && normalizeRef(props),
ref: extraProps && extraProps.ref ? normalizeRef(extraProps) : vnode.ref,
scopeId: vnode.scopeId,
children: vnode.children,
target: vnode.target,