markStaticRoots() — vue Function Reference
Architecture documentation for the markStaticRoots() function in optimizer.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 730159c2_1493_882e_b97a_dc4fac64dcc1["markStaticRoots()"] 47a275bd_2581_aeff_9124_e9298610ab3f["optimize()"] 47a275bd_2581_aeff_9124_e9298610ab3f -->|calls| 730159c2_1493_882e_b97a_dc4fac64dcc1 style 730159c2_1493_882e_b97a_dc4fac64dcc1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/compiler/optimizer.ts lines 72–101
function markStaticRoots(node: ASTNode, isInFor: boolean) {
if (node.type === 1) {
if (node.static || node.once) {
node.staticInFor = isInFor
}
// For a node to qualify as a static root, it should have children that
// are not just static text. Otherwise the cost of hoisting out will
// outweigh the benefits and it's better off to just always render it fresh.
if (
node.static &&
node.children.length &&
!(node.children.length === 1 && node.children[0].type === 3)
) {
node.staticRoot = true
return
} else {
node.staticRoot = false
}
if (node.children) {
for (let i = 0, l = node.children.length; i < l; i++) {
markStaticRoots(node.children[i], isInFor || !!node.for)
}
}
if (node.ifConditions) {
for (let i = 1, l = node.ifConditions.length; i < l; i++) {
markStaticRoots(node.ifConditions[i].block, isInFor)
}
}
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does markStaticRoots() do?
markStaticRoots() is a function in the vue codebase.
What calls markStaticRoots()?
markStaticRoots() is called by 1 function(s): optimize.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free