Home / File/ render-static.ts — vue Source File

render-static.ts — vue Source File

Architecture documentation for render-static.ts, a typescript file in the vue codebase. 2 imports, 1 dependents.

File typescript VueCore GlobalAPI 2 imports 1 dependents 4 functions

Entity Profile

Dependency Diagram

graph LR
  ff793352_554c_f421_d224_78b65a6278df["render-static.ts"]
  973389ac_8625_30a3_53ce_b1b48fae58c5["vnode"]
  ff793352_554c_f421_d224_78b65a6278df --> 973389ac_8625_30a3_53ce_b1b48fae58c5
  6d8f8976_7066_720b_0d45_45fe42921eaf["util"]
  ff793352_554c_f421_d224_78b65a6278df --> 6d8f8976_7066_720b_0d45_45fe42921eaf
  8ffc8513_97a6_feaa_6bc2_e31c949e66cd["index.ts"]
  8ffc8513_97a6_feaa_6bc2_e31c949e66cd --> ff793352_554c_f421_d224_78b65a6278df
  style ff793352_554c_f421_d224_78b65a6278df fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import VNode from 'core/vdom/vnode'
import { isArray } from 'core/util'

/**
 * Runtime helper for rendering static trees.
 */
export function renderStatic(
  index: number,
  isInFor: boolean
): VNode | Array<VNode> {
  const cached = this._staticTrees || (this._staticTrees = [])
  let tree = cached[index]
  // if has already-rendered static tree and not inside v-for,
  // we can reuse the same tree.
  if (tree && !isInFor) {
    return tree
  }
  // otherwise, render a fresh tree.
  tree = cached[index] = this.$options.staticRenderFns[index].call(
    this._renderProxy,
    this._c,
    this // for render fns generated for functional component templates
  )
  markStatic(tree, `__static__${index}`, false)
  return tree
}

/**
 * Runtime helper for v-once.
 * Effectively it means marking the node as static with a unique key.
 */
export function markOnce(
  tree: VNode | Array<VNode>,
  index: number,
  key: string
) {
  markStatic(tree, `__once__${index}${key ? `_${key}` : ``}`, true)
  return tree
}

function markStatic(tree: VNode | Array<VNode>, key: string, isOnce: boolean) {
  if (isArray(tree)) {
    for (let i = 0; i < tree.length; i++) {
      if (tree[i] && typeof tree[i] !== 'string') {
        markStaticNode(tree[i], `${key}_${i}`, isOnce)
      }
    }
  } else {
    markStaticNode(tree, key, isOnce)
  }
}

function markStaticNode(node, key, isOnce) {
  node.isStatic = true
  node.key = key
  node.isOnce = isOnce
}

Domain

Subdomains

Dependencies

  • util
  • vnode

Frequently Asked Questions

What does render-static.ts do?
render-static.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, GlobalAPI subdomain.
What functions are defined in render-static.ts?
render-static.ts defines 4 function(s): markOnce, markStatic, markStaticNode, renderStatic.
What does render-static.ts depend on?
render-static.ts imports 2 module(s): util, vnode.
What files import render-static.ts?
render-static.ts is imported by 1 file(s): index.ts.
Where is render-static.ts in the architecture?
render-static.ts is located at src/core/instance/render-helpers/render-static.ts (domain: VueCore, subdomain: GlobalAPI, directory: src/core/instance/render-helpers).

Analyze Your Own Codebase

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

Try Supermodel Free