Home / Function/ genOnce() — vue Function Reference

genOnce() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  baea1fd5_74ae_11db_8cec_d9ecde977f21["genOnce()"]
  4cfaef88_0bc8_30fc_0a01_09b4149fd58c["genElement()"]
  4cfaef88_0bc8_30fc_0a01_09b4149fd58c -->|calls| baea1fd5_74ae_11db_8cec_d9ecde977f21
  df86dcf0_a271_3752_194d_d6d9e475ec59["genIfConditions()"]
  df86dcf0_a271_3752_194d_d6d9e475ec59 -->|calls| baea1fd5_74ae_11db_8cec_d9ecde977f21
  e458f6c9_a80f_c2c4_a63b_541be2a8b2b9["genIf()"]
  baea1fd5_74ae_11db_8cec_d9ecde977f21 -->|calls| e458f6c9_a80f_c2c4_a63b_541be2a8b2b9
  4cfaef88_0bc8_30fc_0a01_09b4149fd58c["genElement()"]
  baea1fd5_74ae_11db_8cec_d9ecde977f21 -->|calls| 4cfaef88_0bc8_30fc_0a01_09b4149fd58c
  8d54f6c4_d0ee_4328_66df_a6c8aa0a56aa["genStatic()"]
  baea1fd5_74ae_11db_8cec_d9ecde977f21 -->|calls| 8d54f6c4_d0ee_4328_66df_a6c8aa0a56aa
  style baea1fd5_74ae_11db_8cec_d9ecde977f21 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/compiler/codegen/index.ts lines 174–200

function genOnce(el: ASTElement, state: CodegenState): string {
  el.onceProcessed = true
  if (el.if && !el.ifProcessed) {
    return genIf(el, state)
  } else if (el.staticInFor) {
    let key = ''
    let parent = el.parent
    while (parent) {
      if (parent.for) {
        key = parent.key!
        break
      }
      parent = parent.parent
    }
    if (!key) {
      __DEV__ &&
        state.warn(
          `v-once can only be used inside v-for that is keyed. `,
          el.rawAttrsMap['v-once']
        )
      return genElement(el, state)
    }
    return `_o(${genElement(el, state)},${state.onceId++},${key})`
  } else {
    return genStatic(el, state)
  }
}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free