preTransformNode() — vue Function Reference
Architecture documentation for the preTransformNode() function in model.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 50372dba_f1ee_d8c7_333f_1e84f4be8133["preTransformNode()"] 8d4b3bc0_2b00_3a5a_262b_e9264265970e["model.ts"] 50372dba_f1ee_d8c7_333f_1e84f4be8133 -->|defined in| 8d4b3bc0_2b00_3a5a_262b_e9264265970e a0a70174_f399_7b4b_6149_5c2c224f772f["cloneASTElement()"] 50372dba_f1ee_d8c7_333f_1e84f4be8133 -->|calls| a0a70174_f399_7b4b_6149_5c2c224f772f style 50372dba_f1ee_d8c7_333f_1e84f4be8133 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/platforms/web/compiler/modules/model.ts lines 21–81
function preTransformNode(el: ASTElement, options: CompilerOptions) {
if (el.tag === 'input') {
const map = el.attrsMap
if (!map['v-model']) {
return
}
let typeBinding
if (map[':type'] || map['v-bind:type']) {
typeBinding = getBindingAttr(el, 'type')
}
if (!map.type && !typeBinding && map['v-bind']) {
typeBinding = `(${map['v-bind']}).type`
}
if (typeBinding) {
const ifCondition = getAndRemoveAttr(el, 'v-if', true)
const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``
const hasElse = getAndRemoveAttr(el, 'v-else', true) != null
const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true)
// 1. checkbox
const branch0 = cloneASTElement(el)
// process for on the main node
processFor(branch0)
addRawAttr(branch0, 'type', 'checkbox')
processElement(branch0, options)
branch0.processed = true // prevent it from double-processed
branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra
addIfCondition(branch0, {
exp: branch0.if,
block: branch0
})
// 2. add radio else-if condition
const branch1 = cloneASTElement(el)
getAndRemoveAttr(branch1, 'v-for', true)
addRawAttr(branch1, 'type', 'radio')
processElement(branch1, options)
addIfCondition(branch0, {
exp: `(${typeBinding})==='radio'` + ifConditionExtra,
block: branch1
})
// 3. other
const branch2 = cloneASTElement(el)
getAndRemoveAttr(branch2, 'v-for', true)
addRawAttr(branch2, ':type', typeBinding)
processElement(branch2, options)
addIfCondition(branch0, {
exp: ifCondition!,
block: branch2
})
if (hasElse) {
branch0.else = true
} else if (elseIfCondition) {
branch0.elseif = elseIfCondition
}
return branch0
}
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does preTransformNode() do?
preTransformNode() is a function in the vue codebase, defined in src/platforms/web/compiler/modules/model.ts.
Where is preTransformNode() defined?
preTransformNode() is defined in src/platforms/web/compiler/modules/model.ts at line 21.
What does preTransformNode() call?
preTransformNode() calls 1 function(s): cloneASTElement.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free