registerRef() — vue Function Reference
Architecture documentation for the registerRef() function in template-ref.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD e4d4b46d_5073_fac6_177d_53fc5028052b["registerRef()"] ceeb9b13_34d7_177d_f00f_e9f463e6ebb5["template-ref.ts"] e4d4b46d_5073_fac6_177d_53fc5028052b -->|defined in| ceeb9b13_34d7_177d_f00f_e9f463e6ebb5 635d57c6_8d9e_ee3b_a13e_c25585a06c27["default.create()"] 635d57c6_8d9e_ee3b_a13e_c25585a06c27 -->|calls| e4d4b46d_5073_fac6_177d_53fc5028052b d5611b31_668e_5cf1_a151_f2d54eb4b708["default.update()"] d5611b31_668e_5cf1_a151_f2d54eb4b708 -->|calls| e4d4b46d_5073_fac6_177d_53fc5028052b 49e5dfdd_1da7_7dc0_5c40_2511c342ea3e["default.destroy()"] 49e5dfdd_1da7_7dc0_5c40_2511c342ea3e -->|calls| e4d4b46d_5073_fac6_177d_53fc5028052b 3bb2ae4b_c366_ee68_8304_5578e138a454["createPatchFunction()"] 3bb2ae4b_c366_ee68_8304_5578e138a454 -->|calls| e4d4b46d_5073_fac6_177d_53fc5028052b dd0d5082_6acb_62e7_40e5_ee9478a135de["setSetupRef()"] e4d4b46d_5073_fac6_177d_53fc5028052b -->|calls| dd0d5082_6acb_62e7_40e5_ee9478a135de style e4d4b46d_5073_fac6_177d_53fc5028052b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/core/vdom/modules/template-ref.ts lines 29–80
export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) {
const ref = vnode.data.ref
if (!isDef(ref)) return
const vm = vnode.context
const refValue = vnode.componentInstance || vnode.elm
const value = isRemoval ? null : refValue
const $refsValue = isRemoval ? undefined : refValue
if (isFunction(ref)) {
invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`)
return
}
const isFor = vnode.data.refInFor
const _isString = typeof ref === 'string' || typeof ref === 'number'
const _isRef = isRef(ref)
const refs = vm.$refs
if (_isString || _isRef) {
if (isFor) {
const existing = _isString ? refs[ref] : ref.value
if (isRemoval) {
isArray(existing) && remove(existing, refValue)
} else {
if (!isArray(existing)) {
if (_isString) {
refs[ref] = [refValue]
setSetupRef(vm, ref, refs[ref])
} else {
ref.value = [refValue]
}
} else if (!existing.includes(refValue)) {
existing.push(refValue)
}
}
} else if (_isString) {
if (isRemoval && refs[ref] !== refValue) {
return
}
refs[ref] = $refsValue
setSetupRef(vm, ref, value)
} else if (_isRef) {
if (isRemoval && ref.value !== refValue) {
return
}
ref.value = value
} else if (__DEV__) {
warn(`Invalid template ref type: ${typeof ref}`)
}
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does registerRef() do?
registerRef() is a function in the vue codebase, defined in src/core/vdom/modules/template-ref.ts.
Where is registerRef() defined?
registerRef() is defined in src/core/vdom/modules/template-ref.ts at line 29.
What does registerRef() call?
registerRef() calls 1 function(s): setSetupRef.
What calls registerRef()?
registerRef() is called by 4 function(s): createPatchFunction, default.create, default.destroy, default.update.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free