MCPcopy Create free account
hub / github.com/dashnowords/imfe / patchVnode

Function patchVnode

chapter17/vue.js:6259–6332  ·  view source on GitHub ↗
(
      oldVnode,
      vnode,
      insertedVnodeQueue,
      ownerArray,
      index,
      removeOnly
    )

Source from the content-addressed store, hash-verified

6257 }
6258
6259 function patchVnode (
6260 oldVnode,
6261 vnode,
6262 insertedVnodeQueue,
6263 ownerArray,
6264 index,
6265 removeOnly
6266 ) {
6267 if (oldVnode === vnode) {
6268 return
6269 }
6270
6271 if (isDef(vnode.elm) && isDef(ownerArray)) {
6272 // clone reused vnode
6273 vnode = ownerArray[index] = cloneVNode(vnode);
6274 }
6275
6276 var elm = vnode.elm = oldVnode.elm;
6277
6278 if (isTrue(oldVnode.isAsyncPlaceholder)) {
6279 if (isDef(vnode.asyncFactory.resolved)) {
6280 hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
6281 } else {
6282 vnode.isAsyncPlaceholder = true;
6283 }
6284 return
6285 }
6286
6287 // reuse element for static trees.
6288 // note we only do this if the vnode is cloned -
6289 // if the new node is not cloned it means the render functions have been
6290 // reset by the hot-reload-api and we need to do a proper re-render.
6291 if (isTrue(vnode.isStatic) &&
6292 isTrue(oldVnode.isStatic) &&
6293 vnode.key === oldVnode.key &&
6294 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
6295 ) {
6296 vnode.componentInstance = oldVnode.componentInstance;
6297 return
6298 }
6299
6300 var i;
6301 var data = vnode.data;
6302 if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
6303 i(oldVnode, vnode);
6304 }
6305
6306 var oldCh = oldVnode.children;
6307 var ch = vnode.children;
6308 if (isDef(data) && isPatchable(vnode)) {
6309 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
6310 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
6311 }
6312 if (isUndef(vnode.text)) {
6313 if (isDef(oldCh) && isDef(ch)) {
6314 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
6315 } else if (isDef(ch)) {
6316 {

Callers 2

updateChildrenFunction · 0.85
createPatchFunctionFunction · 0.85

Calls 11

isDefFunction · 0.85
cloneVNodeFunction · 0.85
isTrueFunction · 0.85
hydrateFunction · 0.85
isPatchableFunction · 0.85
isUndefFunction · 0.85
updateChildrenFunction · 0.85
checkDuplicateKeysFunction · 0.85
addVnodesFunction · 0.85
removeVnodesFunction · 0.85
iFunction · 0.50

Tested by

no test coverage detected