Home / Function/ markStaticRoots() — vue Function Reference

markStaticRoots() — vue Function Reference

Architecture documentation for the markStaticRoots() function in optimizer.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  a319c2c8_c1df_c464_6a20_a951bed08523["markStaticRoots()"]
  c66d4aaa_9814_c96c_1d3f_ef17ed6ab384["optimizer.ts"]
  a319c2c8_c1df_c464_6a20_a951bed08523 -->|defined in| c66d4aaa_9814_c96c_1d3f_ef17ed6ab384
  53eb02a0_e5cc_b010_2d4d_1ad77bf5eb9c["optimize()"]
  53eb02a0_e5cc_b010_2d4d_1ad77bf5eb9c -->|calls| a319c2c8_c1df_c464_6a20_a951bed08523
  style a319c2c8_c1df_c464_6a20_a951bed08523 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

Frequently Asked Questions

What does markStaticRoots() do?
markStaticRoots() is a function in the vue codebase, defined in src/compiler/optimizer.ts.
Where is markStaticRoots() defined?
markStaticRoots() is defined in src/compiler/optimizer.ts at line 72.
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