wip(vapor): fix v-for update check + avoid unnecessary tracking overhead during diff

This commit is contained in:
Evan You 2025-02-09 12:14:31 +08:00
parent 69422d50d8
commit 11383ae72d
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
1 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,8 @@ import {
type ShallowRef,
isReactive,
isShallow,
pauseTracking,
resetTracking,
shallowReadArray,
shallowRef,
toReactive,
@ -88,6 +90,8 @@ export const createFor = (
const oldLength = oldBlocks.length
newBlocks = new Array(newLength)
pauseTracking()
if (!isMounted) {
isMounted = true
for (let i = 0; i < newLength; i++) {
@ -269,6 +273,8 @@ export const createFor = (
if (parentAnchor) {
frag.nodes.push(parentAnchor)
}
resetTracking()
}
const needKey = renderItem.length > 1
@ -326,7 +332,7 @@ export const createFor = (
newKey?: any,
newIndex?: any,
) => {
if (newIndex !== itemRef.value) {
if (newItem !== itemRef.value) {
itemRef.value = newItem
}
if (keyRef && newKey !== undefined && newKey !== keyRef.value) {