fix(runtime-core/refs): handle multiple merged refs for dynamic component with vnode
fix #2078
This commit is contained in:
@@ -10,7 +10,8 @@ import {
|
||||
isSameVNodeType,
|
||||
Static,
|
||||
VNodeNormalizedRef,
|
||||
VNodeHook
|
||||
VNodeHook,
|
||||
VNodeNormalizedRefAtom
|
||||
} from './vnode'
|
||||
import {
|
||||
ComponentInternalInstance,
|
||||
@@ -284,6 +285,19 @@ export const setRef = (
|
||||
parentSuspense: SuspenseBoundary | null,
|
||||
vnode: VNode | null
|
||||
) => {
|
||||
if (isArray(rawRef)) {
|
||||
rawRef.forEach((r, i) =>
|
||||
setRef(
|
||||
r,
|
||||
oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
|
||||
parentComponent,
|
||||
parentSuspense,
|
||||
vnode
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
let value: ComponentPublicInstance | RendererNode | null
|
||||
if (!vnode) {
|
||||
value = null
|
||||
@@ -295,7 +309,7 @@ export const setRef = (
|
||||
}
|
||||
}
|
||||
|
||||
const [owner, ref] = rawRef
|
||||
const { i: owner, r: ref } = rawRef
|
||||
if (__DEV__ && !owner) {
|
||||
warn(
|
||||
`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
|
||||
@@ -303,7 +317,7 @@ export const setRef = (
|
||||
)
|
||||
return
|
||||
}
|
||||
const oldRef = oldRawRef && oldRawRef[1]
|
||||
const oldRef = oldRawRef && (oldRawRef as VNodeNormalizedRefAtom).r
|
||||
const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs
|
||||
const setupState = owner.setupState
|
||||
|
||||
|
||||
Reference in New Issue
Block a user