Home / File/ vnode.ts — vue Source File

vnode.ts — vue Source File

Architecture documentation for vnode.ts, a typescript file in the vue codebase. 3 imports, 13 dependents.

File typescript CoreRuntime VirtualDOM 3 imports 13 dependents 3 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  a13b4a2c_7af7_bcfd_03a9_13286f908ca0["vnode.ts"]
  907f4994_ea28_43b1_7976_0db9f0e97637["component"]
  a13b4a2c_7af7_bcfd_03a9_13286f908ca0 --> 907f4994_ea28_43b1_7976_0db9f0e97637
  71d4d16e_1e05_b2c6_a873_5b0a8828ba20["options"]
  a13b4a2c_7af7_bcfd_03a9_13286f908ca0 --> 71d4d16e_1e05_b2c6_a873_5b0a8828ba20
  81ed4f13_7d68_6e21_7425_cf978f68576f["vnode"]
  a13b4a2c_7af7_bcfd_03a9_13286f908ca0 --> 81ed4f13_7d68_6e21_7425_cf978f68576f
  f3560440_54c1_5663_36f8_c7de54d7310b["lifecycle.ts"]
  f3560440_54c1_5663_36f8_c7de54d7310b --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  a8c0285c_59b2_d81b_1af0_c0cd9c2afe2d["render.ts"]
  a8c0285c_59b2_d81b_1af0_c0cd9c2afe2d --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  012c0986_6b9d_ad59_8fba_57884312dd3b["index.ts"]
  012c0986_6b9d_ad59_8fba_57884312dd3b --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  e9c21780_b26b_d883_76bb_2657a89bfce1["traverse.ts"]
  e9c21780_b26b_d883_76bb_2657a89bfce1 --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  a6875054_df8a_0ce4_8a16_374ce422dc53["create-component.ts"]
  a6875054_df8a_0ce4_8a16_374ce422dc53 --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  ed56e0c4_2667_3b26_6b70_35cd51b08810["create-element.ts"]
  ed56e0c4_2667_3b26_6b70_35cd51b08810 --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  dfa00dc1_b5e1_fc4b_364c_221e22660e03["create-functional-component.ts"]
  dfa00dc1_b5e1_fc4b_364c_221e22660e03 --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  6f1eb452_db8c_d8eb_6413_b06818fd50ff["get-first-component-child.ts"]
  6f1eb452_db8c_d8eb_6413_b06818fd50ff --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  22dbd5d8_751a_f3d4_c38c_61927e291141["is-async-placeholder.ts"]
  22dbd5d8_751a_f3d4_c38c_61927e291141 --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  1d9d4118_665c_f6c2_cd3e_e1c7a7b6e252["merge-hook.ts"]
  1d9d4118_665c_f6c2_cd3e_e1c7a7b6e252 --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  81712410_81a9_d297_5ff3_adabfc4f54fd["normalize-scoped-slots.ts"]
  81712410_81a9_d297_5ff3_adabfc4f54fd --> a13b4a2c_7af7_bcfd_03a9_13286f908ca0
  style a13b4a2c_7af7_bcfd_03a9_13286f908ca0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Component } from 'types/component'
import type { ComponentOptions } from 'types/options'
import type { VNodeComponentOptions, VNodeData } from 'types/vnode'

/**
 * @internal
 */
export default class VNode {
  tag?: string
  data: VNodeData | undefined
  children?: Array<VNode> | null
  text?: string
  elm: Node | undefined
  ns?: string
  context?: Component // rendered in this component's scope
  key: string | number | undefined
  componentOptions?: VNodeComponentOptions
  componentInstance?: Component // component instance
  parent: VNode | undefined | null // component placeholder node

  // strictly internal
  raw: boolean // contains raw HTML? (server only)
  isStatic: boolean // hoisted static node
  isRootInsert: boolean // necessary for enter transition check
  isComment: boolean // empty comment placeholder?
  isCloned: boolean // is a cloned node?
  isOnce: boolean // is a v-once node?
  asyncFactory?: Function // async component factory function
  asyncMeta: Object | void
  isAsyncPlaceholder: boolean
  ssrContext?: Object | void
  fnContext: Component | void // real context vm for functional nodes
  fnOptions?: ComponentOptions | null // for SSR caching
  devtoolsMeta?: Object | null // used to store functional render context for devtools
  fnScopeId?: string | null // functional scope id support
  isComponentRootElement?: boolean | null // for SSR directives

  constructor(
    tag?: string,
    data?: VNodeData,
    children?: Array<VNode> | null,
    text?: string,
    elm?: Node,
    context?: Component,
    componentOptions?: VNodeComponentOptions,
    asyncFactory?: Function
  ) {
    this.tag = tag
    this.data = data
    this.children = children
    this.text = text
    this.elm = elm
    this.ns = undefined
    this.context = context
    this.fnContext = undefined
    this.fnOptions = undefined
    this.fnScopeId = undefined
    this.key = data && data.key
    this.componentOptions = componentOptions
    this.componentInstance = undefined
    this.parent = undefined
    this.raw = false
    this.isStatic = false
    this.isRootInsert = true
    this.isComment = false
    this.isCloned = false
    this.isOnce = false
    this.asyncFactory = asyncFactory
    this.asyncMeta = undefined
    this.isAsyncPlaceholder = false
  }

  // DEPRECATED: alias for componentInstance for backwards compat.
  /* istanbul ignore next */
  get child(): Component | void {
    return this.componentInstance
  }
}

export const createEmptyVNode = (text: string = '') => {
  const node = new VNode()
  node.text = text
  node.isComment = true
  return node
}

export function createTextVNode(val: string | number) {
  return new VNode(undefined, undefined, undefined, String(val))
}

// optimized shallow clone
// used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference.
export function cloneVNode(vnode: VNode): VNode {
  const cloned = new VNode(
    vnode.tag,
    vnode.data,
    // #7975
    // clone children array to avoid mutating original in case of cloning
    // a child.
    vnode.children && vnode.children.slice(),
    vnode.text,
    vnode.elm,
    vnode.context,
    vnode.componentOptions,
    vnode.asyncFactory
  )
  cloned.ns = vnode.ns
  cloned.isStatic = vnode.isStatic
  cloned.key = vnode.key
  cloned.isComment = vnode.isComment
  cloned.fnContext = vnode.fnContext
  cloned.fnOptions = vnode.fnOptions
  cloned.fnScopeId = vnode.fnScopeId
  cloned.asyncMeta = vnode.asyncMeta
  cloned.isCloned = true
  return cloned
}

Domain

Subdomains

Classes

Dependencies

  • component
  • options
  • vnode

Frequently Asked Questions

What does vnode.ts do?
vnode.ts is a source file in the vue codebase, written in typescript. It belongs to the CoreRuntime domain, VirtualDOM subdomain.
What functions are defined in vnode.ts?
vnode.ts defines 3 function(s): cloneVNode, createEmptyVNode, createTextVNode.
What does vnode.ts depend on?
vnode.ts imports 3 module(s): component, options, vnode.
What files import vnode.ts?
vnode.ts is imported by 13 file(s): apiSetup.ts, create-component.ts, create-element.ts, create-functional-component.ts, get-first-component-child.ts, index.ts, is-async-placeholder.ts, lifecycle.ts, and 5 more.
Where is vnode.ts in the architecture?
vnode.ts is located at src/core/vdom/vnode.ts (domain: CoreRuntime, subdomain: VirtualDOM, directory: src/core/vdom).

Analyze Your Own Codebase

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

Try Supermodel Free