Skip to content

Commit 58949bd

Browse files
committed
use sameVnode check when pacthing keyed children (fix vuejs#4393)
1 parent b48c45e commit 58949bd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/core/vdom/patch.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,15 @@ export function createPatchFunction (backend) {
386386
'Make sure each v-for item has a unique key.'
387387
)
388388
}
389-
if (elmToMove.tag !== newStartVnode.tag) {
390-
// same key but different element. treat as new element
391-
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm)
392-
newStartVnode = newCh[++newStartIdx]
393-
} else {
389+
if (sameVnode(elmToMove, newStartVnode)) {
394390
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue)
395391
oldCh[idxInOld] = undefined
396392
canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm)
397393
newStartVnode = newCh[++newStartIdx]
394+
} else {
395+
// same key but different element. treat as new element
396+
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm)
397+
newStartVnode = newCh[++newStartIdx]
398398
}
399399
}
400400
}

0 commit comments

Comments
 (0)