MCPcopy Create free account
hub / github.com/TruthHun/BookStack / patchVnode

Function patchVnode

static/vuejs/vue.esm.js:4904–4949  ·  view source on GitHub ↗
(oldVnode, vnode, insertedVnodeQueue, removeOnly)

Source from the content-addressed store, hash-verified

4902 }
4903
4904 function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
4905 if (oldVnode === vnode) {
4906 return
4907 }
4908 // reuse element for static trees.
4909 // note we only do this if the vnode is cloned -
4910 // if the new node is not cloned it means the render functions have been
4911 // reset by the hot-reload-api and we need to do a proper re-render.
4912 if (isTrue(vnode.isStatic) &&
4913 isTrue(oldVnode.isStatic) &&
4914 vnode.key === oldVnode.key &&
4915 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
4916 vnode.elm = oldVnode.elm;
4917 vnode.componentInstance = oldVnode.componentInstance;
4918 return
4919 }
4920 var i;
4921 var data = vnode.data;
4922 if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
4923 i(oldVnode, vnode);
4924 }
4925 var elm = vnode.elm = oldVnode.elm;
4926 var oldCh = oldVnode.children;
4927 var ch = vnode.children;
4928 if (isDef(data) && isPatchable(vnode)) {
4929 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
4930 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
4931 }
4932 if (isUndef(vnode.text)) {
4933 if (isDef(oldCh) && isDef(ch)) {
4934 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
4935 } else if (isDef(ch)) {
4936 if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
4937 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
4938 } else if (isDef(oldCh)) {
4939 removeVnodes(elm, oldCh, 0, oldCh.length - 1);
4940 } else if (isDef(oldVnode.text)) {
4941 nodeOps.setTextContent(elm, '');
4942 }
4943 } else if (oldVnode.text !== vnode.text) {
4944 nodeOps.setTextContent(elm, vnode.text);
4945 }
4946 if (isDef(data)) {
4947 if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
4948 }
4949 }
4950
4951 function invokeInsertHook (vnode, queue, initial) {
4952 // delay insert hooks for component root nodes, invoke them after the

Callers 2

updateChildrenFunction · 0.70
createPatchFunctionFunction · 0.70

Calls 8

isTrueFunction · 0.70
isDefFunction · 0.70
iFunction · 0.70
isPatchableFunction · 0.70
isUndefFunction · 0.70
updateChildrenFunction · 0.70
addVnodesFunction · 0.70
removeVnodesFunction · 0.70

Tested by

no test coverage detected