Skip to content

Commit af4ade5

Browse files
committed
v-for: adjustments to (key,val) syntax
1 parent a8a7ca2 commit af4ade5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/directives/for.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ module.exports = {
1616
if (inMatch) {
1717
var itMatch = inMatch[1].match(/\((.*),(.*)\)/)
1818
if (itMatch) {
19-
this.iterator = itMatch[1]
20-
this.alias = itMatch[2]
19+
this.iterator = itMatch[1].trim()
20+
this.alias = itMatch[2].trim()
2121
} else {
22-
this.alias = inMatch[1]
22+
this.alias = inMatch[1].trim()
2323
}
2424
this._watcherExp = inMatch[2]
2525
}
@@ -107,6 +107,7 @@ module.exports = {
107107
var oldFrags = this.frags
108108
var frags = this.frags = new Array(data.length)
109109
var alias = this.alias
110+
var iterator = this.iterator
110111
var start = this.start
111112
var end = this.end
112113
var inDoc = _.inDoc(start)
@@ -130,6 +131,9 @@ module.exports = {
130131
// update $key
131132
if (key) {
132133
frag.scope.$key = key
134+
if (iterator) {
135+
frag.scope[iterator] = key
136+
}
133137
}
134138
// update data for track-by, object repeat &
135139
// primitive values.

0 commit comments

Comments
 (0)