From: Evan You Date: Sun, 9 Feb 2025 04:14:31 +0000 (+0800) Subject: wip(vapor): fix v-for update check + avoid unnecessary tracking overhead during diff X-Git-Tag: v3.6.0-alpha.1~16^2~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=11383ae72d233aeaf4cf3cb838955a9bbb5a4484;p=thirdparty%2Fvuejs%2Fcore.git wip(vapor): fix v-for update check + avoid unnecessary tracking overhead during diff --- diff --git a/packages/runtime-vapor/src/apiCreateFor.ts b/packages/runtime-vapor/src/apiCreateFor.ts index 1bce641635..1d6d719011 100644 --- a/packages/runtime-vapor/src/apiCreateFor.ts +++ b/packages/runtime-vapor/src/apiCreateFor.ts @@ -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) {