]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip(vapor): fix v-for update check + avoid unnecessary tracking overhead during diff
authorEvan You <evan@vuejs.org>
Sun, 9 Feb 2025 04:14:31 +0000 (12:14 +0800)
committerEvan You <evan@vuejs.org>
Sun, 9 Feb 2025 04:14:31 +0000 (12:14 +0800)
packages/runtime-vapor/src/apiCreateFor.ts

index 1bce641635651efdf6baac490a07ddbb03e80a14..1d6d7190116611c011fb4ba5991c8c40a6112603 100644 (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) {