Skip to content

Commit bfd505e

Browse files
committed
simplify updateIndex
1 parent 44aa90e commit bfd505e

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/directives/repeat.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ module.exports = {
106106
var method = mutation.method
107107
mutationHandlers[method].call(self, mutation)
108108
if (method !== 'push' && method !== 'pop') {
109-
self.updateIndex()
109+
var i = arr.length
110+
while (i--) {
111+
arr[i].$index = i
112+
}
110113
}
111114
if (method === 'push' || method === 'unshift' || method === 'splice') {
112115
self.changed()
@@ -223,16 +226,6 @@ module.exports = {
223226
}
224227
},
225228

226-
/**
227-
* Update index of each item after a mutation
228-
*/
229-
updateIndex: function () {
230-
var i = this.vms.length
231-
while (i--) {
232-
this.vms[i].$data.$index = i
233-
}
234-
},
235-
236229
reset: function () {
237230
if (this.childId) {
238231
delete this.vm.$[this.childId]

0 commit comments

Comments
 (0)