Explorar o código

simplify updateIndex

Evan You %!s(int64=12) %!d(string=hai) anos
pai
achega
bfd505efb2
Modificáronse 1 ficheiros con 4 adicións e 11 borrados
  1. 4 11
      src/directives/repeat.js

+ 4 - 11
src/directives/repeat.js

@@ -106,7 +106,10 @@ module.exports = {
             var method = mutation.method
             mutationHandlers[method].call(self, mutation)
             if (method !== 'push' && method !== 'pop') {
-                self.updateIndex()
+                var i = arr.length
+                while (i--) {
+                    arr[i].$index = i
+                }
             }
             if (method === 'push' || method === 'unshift' || method === 'splice') {
                 self.changed()
@@ -223,16 +226,6 @@ module.exports = {
         }
     },
 
-    /**
-     *  Update index of each item after a mutation
-     */
-    updateIndex: function () {
-        var i = this.vms.length
-        while (i--) {
-            this.vms[i].$data.$index = i
-        }
-    },
-
     reset: function () {
         if (this.childId) {
             delete this.vm.$[this.childId]