Home / Function/ genIfConditions() — vue Function Reference

genIfConditions() — vue Function Reference

Architecture documentation for the genIfConditions() function in index.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  5e8059c6_fb22_746e_61a2_86676c11cb7a["genIfConditions()"]
  e7c86dbc_f669_e04c_eae5_85c469684781["genIf()"]
  e7c86dbc_f669_e04c_eae5_85c469684781 -->|calls| 5e8059c6_fb22_746e_61a2_86676c11cb7a
  56d1ac63_81aa_e60d_9132_8fea48dc8c53["genOnce()"]
  5e8059c6_fb22_746e_61a2_86676c11cb7a -->|calls| 56d1ac63_81aa_e60d_9132_8fea48dc8c53
  ce806ab8_847b_273b_e07c_0a796c2f76ae["genElement()"]
  5e8059c6_fb22_746e_61a2_86676c11cb7a -->|calls| ce806ab8_847b_273b_e07c_0a796c2f76ae
  style 5e8059c6_fb22_746e_61a2_86676c11cb7a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/compiler/codegen/index.ts lines 212–239

function genIfConditions(
  conditions: ASTIfConditions,
  state: CodegenState,
  altGen?: Function,
  altEmpty?: string
): string {
  if (!conditions.length) {
    return altEmpty || '_e()'
  }

  const condition = conditions.shift()!
  if (condition.exp) {
    return `(${condition.exp})?${genTernaryExp(
      condition.block
    )}:${genIfConditions(conditions, state, altGen, altEmpty)}`
  } else {
    return `${genTernaryExp(condition.block)}`
  }

  // v-if with v-once should generate code like (a)?_m(0):_m(1)
  function genTernaryExp(el) {
    return altGen
      ? altGen(el, state)
      : el.once
      ? genOnce(el, state)
      : genElement(el, state)
  }
}

Subdomains

Called By

Frequently Asked Questions

What does genIfConditions() do?
genIfConditions() is a function in the vue codebase.
What does genIfConditions() call?
genIfConditions() calls 2 function(s): genElement, genOnce.
What calls genIfConditions()?
genIfConditions() is called by 1 function(s): genIf.

Analyze Your Own Codebase

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

Try Supermodel Free