Home / Function/ createPatchFunction() — vue Function Reference

createPatchFunction() — vue Function Reference

Architecture documentation for the createPatchFunction() function in patch.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  dca56857_b66b_81ec_c7d3_4029eaf84e02["createPatchFunction()"]
  020681fa_600e_5c84_6a4e_f1289077cc78["patch.ts"]
  dca56857_b66b_81ec_c7d3_4029eaf84e02 -->|defined in| 020681fa_600e_5c84_6a4e_f1289077cc78
  a14a84ee_0539_7537_3b2a_242996539b59["cloneVNode()"]
  dca56857_b66b_81ec_c7d3_4029eaf84e02 -->|calls| a14a84ee_0539_7537_3b2a_242996539b59
  ac2a5d8a_d8a3_117c_7f0d_cb9b1b084b59["registerRef()"]
  dca56857_b66b_81ec_c7d3_4029eaf84e02 -->|calls| ac2a5d8a_d8a3_117c_7f0d_cb9b1b084b59
  6818a46b_6353_f7ba_68e1_b56cd8b066ef["sameVnode()"]
  dca56857_b66b_81ec_c7d3_4029eaf84e02 -->|calls| 6818a46b_6353_f7ba_68e1_b56cd8b066ef
  cbc791b1_c559_f57b_c841_3027937f5759["createKeyToOldIdx()"]
  dca56857_b66b_81ec_c7d3_4029eaf84e02 -->|calls| cbc791b1_c559_f57b_c841_3027937f5759
  1590b3d4_b603_9a95_ff78_1330c383e860["traverse()"]
  dca56857_b66b_81ec_c7d3_4029eaf84e02 -->|calls| 1590b3d4_b603_9a95_ff78_1330c383e860
  style dca56857_b66b_81ec_c7d3_4029eaf84e02 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/vdom/patch.ts lines 66–907

export function createPatchFunction(backend) {
  let i, j
  const cbs: any = {}

  const { modules, nodeOps } = backend

  for (i = 0; i < hooks.length; ++i) {
    cbs[hooks[i]] = []
    for (j = 0; j < modules.length; ++j) {
      if (isDef(modules[j][hooks[i]])) {
        cbs[hooks[i]].push(modules[j][hooks[i]])
      }
    }
  }

  function emptyNodeAt(elm) {
    return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  }

  function createRmCb(childElm, listeners) {
    function remove() {
      if (--remove.listeners === 0) {
        removeNode(childElm)
      }
    }
    remove.listeners = listeners
    return remove
  }

  function removeNode(el) {
    const parent = nodeOps.parentNode(el)
    // element may have already been removed due to v-html / v-text
    if (isDef(parent)) {
      nodeOps.removeChild(parent, el)
    }
  }

  function isUnknownElement(vnode, inVPre) {
    return (
      !inVPre &&
      !vnode.ns &&
      !(
        config.ignoredElements.length &&
        config.ignoredElements.some(ignore => {
          return isRegExp(ignore)
            ? ignore.test(vnode.tag)
            : ignore === vnode.tag
        })
      ) &&
      config.isUnknownElement(vnode.tag)
    )
  }

  let creatingElmInVPre = 0

  function createElm(
    vnode,
    insertedVnodeQueue,
    parentElm?: any,
    refElm?: any,
    nested?: any,
    ownerArray?: any,
    index?: any
  ) {
    if (isDef(vnode.elm) && isDef(ownerArray)) {
      // This vnode was used in a previous render!
      // now it's used as a new node, overwriting its elm would cause
      // potential patch errors down the road when it's used as an insertion
      // reference node. Instead, we clone the node on-demand before creating
      // associated DOM element for it.
      vnode = ownerArray[index] = cloneVNode(vnode)
    }

    vnode.isRootInsert = !nested // for transition enter check
    if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
      return
    }

    const data = vnode.data
    const children = vnode.children
    const tag = vnode.tag

Domain

Subdomains

Frequently Asked Questions

What does createPatchFunction() do?
createPatchFunction() is a function in the vue codebase, defined in src/core/vdom/patch.ts.
Where is createPatchFunction() defined?
createPatchFunction() is defined in src/core/vdom/patch.ts at line 66.
What does createPatchFunction() call?
createPatchFunction() calls 5 function(s): cloneVNode, createKeyToOldIdx, registerRef, sameVnode, traverse.

Analyze Your Own Codebase

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

Try Supermodel Free