mirror of https://github.com/vuejs/core.git
fix(runtime-vapor): properly handle fast remove in keyed diff
This commit is contained in:
parent
348ffafbc6
commit
07fd7e4d41
|
@ -256,6 +256,7 @@ export const createFor = (
|
||||||
const previousKeyIndexMap = new Map(previousKeyIndexPairs)
|
const previousKeyIndexMap = new Map(previousKeyIndexPairs)
|
||||||
const operations: (() => void)[] = []
|
const operations: (() => void)[] = []
|
||||||
|
|
||||||
|
let mountCounter = 0
|
||||||
const relocateOrMountBlock = (
|
const relocateOrMountBlock = (
|
||||||
blockIndex: number,
|
blockIndex: number,
|
||||||
blockItem: ReturnType<typeof getItem>,
|
blockItem: ReturnType<typeof getItem>,
|
||||||
|
@ -280,6 +281,7 @@ export const createFor = (
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
mountCounter++
|
||||||
operations.push(() =>
|
operations.push(() =>
|
||||||
mount(
|
mount(
|
||||||
source,
|
source,
|
||||||
|
@ -310,7 +312,7 @@ export const createFor = (
|
||||||
relocateOrMountBlock(i, blockItem, blockKey, -1)
|
relocateOrMountBlock(i, blockItem, blockKey, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const useFastRemove = operations.length === newLength
|
const useFastRemove = mountCounter === newLength
|
||||||
|
|
||||||
for (const leftoverIndex of previousKeyIndexMap.values()) {
|
for (const leftoverIndex of previousKeyIndexMap.values()) {
|
||||||
unmount(
|
unmount(
|
||||||
|
|
Loading…
Reference in New Issue