Skip to content

Commit

Permalink
simplify updateIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 14, 2014
1 parent 44aa90e commit bfd505e
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/directives/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit bfd505e

Please sign in to comment.