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

Function patchVnode

static/vuejs/vue.common.js:4906–4951  ·  view source on GitHub ↗
(oldVnode, vnode, insertedVnodeQueue, removeOnly)

Source from the content-addressed store, hash-verified

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