Просмотр исходного кода

use sameVnode check when pacthing keyed children (fix #4393)

Evan You 9 лет назад
Родитель
Сommit
58949bd1c5
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      src/core/vdom/patch.js

+ 5 - 5
src/core/vdom/patch.js

@@ -386,15 +386,15 @@ export function createPatchFunction (backend) {
               'Make sure each v-for item has a unique key.'
             )
           }
-          if (elmToMove.tag !== newStartVnode.tag) {
-            // same key but different element. treat as new element
-            createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm)
-            newStartVnode = newCh[++newStartIdx]
-          } else {
+          if (sameVnode(elmToMove, newStartVnode)) {
             patchVnode(elmToMove, newStartVnode, insertedVnodeQueue)
             oldCh[idxInOld] = undefined
             canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm)
             newStartVnode = newCh[++newStartIdx]
+          } else {
+            // same key but different element. treat as new element
+            createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm)
+            newStartVnode = newCh[++newStartIdx]
           }
         }
       }