Home / Function/ optimizeSiblings() — vue Function Reference

optimizeSiblings() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  e3d52f8e_bef7_0956_84b9_ec934bf8f0e1["optimizeSiblings()"]
  bdccaa53_ff26_818d_5799_6f5b50228230["walk()"]
  bdccaa53_ff26_818d_5799_6f5b50228230 -->|calls| e3d52f8e_bef7_0956_84b9_ec934bf8f0e1
  style e3d52f8e_bef7_0956_84b9_ec934bf8f0e1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/server-renderer/src/optimizing-compiler/optimizer.ts lines 74–108

function optimizeSiblings(el) {
  const children = el.children
  const optimizedChildren: any[] = []

  let currentOptimizableGroup: any[] = []
  const pushGroup = () => {
    if (currentOptimizableGroup.length) {
      optimizedChildren.push({
        type: 1,
        parent: el,
        tag: 'template',
        attrsList: [],
        attrsMap: {},
        rawAttrsMap: {},
        children: currentOptimizableGroup,
        ssrOptimizability: optimizability.FULL
      })
    }
    currentOptimizableGroup = []
  }

  for (let i = 0; i < children.length; i++) {
    const c = children[i]
    if (c.ssrOptimizability === optimizability.FULL) {
      currentOptimizableGroup.push(c)
    } else {
      // wrap fully-optimizable adjacent siblings inside a template tag
      // so that they can be optimized into a single ssrNode by codegen
      pushGroup()
      optimizedChildren.push(c)
    }
  }
  pushGroup()
  return optimizedChildren
}

Subdomains

Called By

Frequently Asked Questions

What does optimizeSiblings() do?
optimizeSiblings() is a function in the vue codebase.
What calls optimizeSiblings()?
optimizeSiblings() is called by 1 function(s): walk.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free