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
  df86dcf0_a271_3752_194d_d6d9e475ec59["genIfConditions()"]
  e458f6c9_a80f_c2c4_a63b_541be2a8b2b9["genIf()"]
  e458f6c9_a80f_c2c4_a63b_541be2a8b2b9 -->|calls| df86dcf0_a271_3752_194d_d6d9e475ec59
  baea1fd5_74ae_11db_8cec_d9ecde977f21["genOnce()"]
  df86dcf0_a271_3752_194d_d6d9e475ec59 -->|calls| baea1fd5_74ae_11db_8cec_d9ecde977f21
  4cfaef88_0bc8_30fc_0a01_09b4149fd58c["genElement()"]
  df86dcf0_a271_3752_194d_d6d9e475ec59 -->|calls| 4cfaef88_0bc8_30fc_0a01_09b4149fd58c
  style df86dcf0_a271_3752_194d_d6d9e475ec59 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)
  }
}

Domain

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