|
|
@@ -434,20 +434,20 @@ export function createPatchFunction (backend) {
|
|
|
} else if (isUndef(oldEndVnode)) {
|
|
|
oldEndVnode = oldCh[--oldEndIdx]
|
|
|
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
|
- patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue)
|
|
|
+ patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx)
|
|
|
oldStartVnode = oldCh[++oldStartIdx]
|
|
|
newStartVnode = newCh[++newStartIdx]
|
|
|
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
|
- patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue)
|
|
|
+ patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx)
|
|
|
oldEndVnode = oldCh[--oldEndIdx]
|
|
|
newEndVnode = newCh[--newEndIdx]
|
|
|
} else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
|
|
|
- patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue)
|
|
|
+ patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx)
|
|
|
canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm))
|
|
|
oldStartVnode = oldCh[++oldStartIdx]
|
|
|
newEndVnode = newCh[--newEndIdx]
|
|
|
} else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
|
|
|
- patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue)
|
|
|
+ patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx)
|
|
|
canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm)
|
|
|
oldEndVnode = oldCh[--oldEndIdx]
|
|
|
newStartVnode = newCh[++newStartIdx]
|
|
|
@@ -461,7 +461,7 @@ export function createPatchFunction (backend) {
|
|
|
} else {
|
|
|
vnodeToMove = oldCh[idxInOld]
|
|
|
if (sameVnode(vnodeToMove, newStartVnode)) {
|
|
|
- patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue)
|
|
|
+ patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx)
|
|
|
oldCh[idxInOld] = undefined
|
|
|
canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm)
|
|
|
} else {
|
|
|
@@ -505,11 +505,23 @@ export function createPatchFunction (backend) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
|
|
|
+ function patchVnode (
|
|
|
+ oldVnode,
|
|
|
+ vnode,
|
|
|
+ insertedVnodeQueue,
|
|
|
+ ownerArray,
|
|
|
+ index,
|
|
|
+ removeOnly
|
|
|
+ ) {
|
|
|
if (oldVnode === vnode) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if (isDef(vnode.elm) && isDef(ownerArray)) {
|
|
|
+ // clone reused vnode
|
|
|
+ vnode = ownerArray[index] = cloneVNode(vnode)
|
|
|
+ }
|
|
|
+
|
|
|
const elm = vnode.elm = oldVnode.elm
|
|
|
|
|
|
if (isTrue(oldVnode.isAsyncPlaceholder)) {
|
|
|
@@ -709,7 +721,7 @@ export function createPatchFunction (backend) {
|
|
|
const isRealElement = isDef(oldVnode.nodeType)
|
|
|
if (!isRealElement && sameVnode(oldVnode, vnode)) {
|
|
|
// patch existing root node
|
|
|
- patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly)
|
|
|
+ patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly)
|
|
|
} else {
|
|
|
if (isRealElement) {
|
|
|
// mounting to a real element
|