]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-vapor): properly handle fast remove in keyed diff minor
authordaiwei <daiwei521@126.com>
Wed, 30 Jul 2025 12:40:36 +0000 (20:40 +0800)
committerdaiwei <daiwei521@126.com>
Wed, 30 Jul 2025 12:40:36 +0000 (20:40 +0800)
packages/runtime-vapor/src/apiCreateFor.ts

index 864bebb8a8d0f7ec15ff28d6eaaca8798842b091..bdd2af7b34857c34435565eba3935a1b631ea947 100644 (file)
@@ -256,6 +256,7 @@ export const createFor = (
           const previousKeyIndexMap = new Map(previousKeyIndexPairs)
           const operations: (() => void)[] = []
 
+          let mountCounter = 0
           const relocateOrMountBlock = (
             blockIndex: number,
             blockItem: ReturnType<typeof getItem>,
@@ -280,6 +281,7 @@ export const createFor = (
                 )
               }
             } else {
+              mountCounter++
               operations.push(() =>
                 mount(
                   source,
@@ -310,7 +312,7 @@ export const createFor = (
             relocateOrMountBlock(i, blockItem, blockKey, -1)
           }
 
-          const useFastRemove = operations.length === newLength
+          const useFastRemove = mountCounter === newLength
 
           for (const leftoverIndex of previousKeyIndexMap.values()) {
             unmount(