Home / Function/ genData() — vue Function Reference

genData() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  4ed91472_8abf_1a34_b708_77e5a59ad407["genData()"]
  f5f4a665_bd43_49ff_d458_cfda193ba027["genNormalElement()"]
  f5f4a665_bd43_49ff_d458_cfda193ba027 -->|calls| 4ed91472_8abf_1a34_b708_77e5a59ad407
  ce806ab8_847b_273b_e07c_0a796c2f76ae["genElement()"]
  ce806ab8_847b_273b_e07c_0a796c2f76ae -->|calls| 4ed91472_8abf_1a34_b708_77e5a59ad407
  d75feb88_2d86_f3b9_e9e7_9bae72b59fc5["genComponent()"]
  d75feb88_2d86_f3b9_e9e7_9bae72b59fc5 -->|calls| 4ed91472_8abf_1a34_b708_77e5a59ad407
  aeacc8fc_2b37_7a25_f121_8fab6166c73a["genDirectives()"]
  4ed91472_8abf_1a34_b708_77e5a59ad407 -->|calls| aeacc8fc_2b37_7a25_f121_8fab6166c73a
  d482b9b1_9071_5444_3def_14cd026c403f["genProps()"]
  4ed91472_8abf_1a34_b708_77e5a59ad407 -->|calls| d482b9b1_9071_5444_3def_14cd026c403f
  6bbf1f50_0df3_4aea_5d48_6eca3f01f5a7["genHandlers()"]
  4ed91472_8abf_1a34_b708_77e5a59ad407 -->|calls| 6bbf1f50_0df3_4aea_5d48_6eca3f01f5a7
  e84bda34_0c0c_e448_e78b_daf80c632a02["genScopedSlots()"]
  4ed91472_8abf_1a34_b708_77e5a59ad407 -->|calls| e84bda34_0c0c_e448_e78b_daf80c632a02
  a16c0a31_a65b_9434_6f1b_e21bfd9517ea["genInlineTemplate()"]
  4ed91472_8abf_1a34_b708_77e5a59ad407 -->|calls| a16c0a31_a65b_9434_6f1b_e21bfd9517ea
  style 4ed91472_8abf_1a34_b708_77e5a59ad407 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/compiler/codegen/index.ts lines 277–359

export function genData(el: ASTElement, state: CodegenState): string {
  let data = '{'

  // directives first.
  // directives may mutate the el's other properties before they are generated.
  const dirs = genDirectives(el, state)
  if (dirs) data += dirs + ','

  // key
  if (el.key) {
    data += `key:${el.key},`
  }
  // ref
  if (el.ref) {
    data += `ref:${el.ref},`
  }
  if (el.refInFor) {
    data += `refInFor:true,`
  }
  // pre
  if (el.pre) {
    data += `pre:true,`
  }
  // record original tag name for components using "is" attribute
  if (el.component) {
    data += `tag:"${el.tag}",`
  }
  // module data generation functions
  for (let i = 0; i < state.dataGenFns.length; i++) {
    data += state.dataGenFns[i](el)
  }
  // attributes
  if (el.attrs) {
    data += `attrs:${genProps(el.attrs)},`
  }
  // DOM props
  if (el.props) {
    data += `domProps:${genProps(el.props)},`
  }
  // event handlers
  if (el.events) {
    data += `${genHandlers(el.events, false)},`
  }
  if (el.nativeEvents) {
    data += `${genHandlers(el.nativeEvents, true)},`
  }
  // slot target
  // only for non-scoped slots
  if (el.slotTarget && !el.slotScope) {
    data += `slot:${el.slotTarget},`
  }
  // scoped slots
  if (el.scopedSlots) {
    data += `${genScopedSlots(el, el.scopedSlots, state)},`
  }
  // component v-model
  if (el.model) {
    data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`
  }
  // inline-template
  if (el.inlineTemplate) {
    const inlineTemplate = genInlineTemplate(el, state)
    if (inlineTemplate) {
      data += `${inlineTemplate},`
    }
  }
  data = data.replace(/,$/, '') + '}'
  // v-bind dynamic argument wrap
  // v-bind with dynamic arguments must be applied using the same v-bind object
  // merge helper so that class/style/mustUseProp attrs are handled correctly.
  if (el.dynamicAttrs) {
    data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`
  }
  // v-bind data wrap
  if (el.wrapData) {
    data = el.wrapData(data)
  }
  // v-on data wrap
  if (el.wrapListeners) {
    data = el.wrapListeners(data)
  }
  return data
}

Subdomains

Frequently Asked Questions

What does genData() do?
genData() is a function in the vue codebase.
What does genData() call?
genData() calls 5 function(s): genDirectives, genHandlers, genInlineTemplate, genProps, genScopedSlots.
What calls genData()?
genData() is called by 3 function(s): genComponent, genElement, genNormalElement.

Analyze Your Own Codebase

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

Try Supermodel Free