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

Function patchVnode

static/vuejs/vue.runtime.js:4896–4941  ·  view source on GitHub ↗
(oldVnode, vnode, insertedVnodeQueue, removeOnly)

Source from the content-addressed store, hash-verified

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