Skip to content

Commit 7a3300a

Browse files
committed
v-for: adjustments to (key,val) syntax
1 parent 42e7a8e commit 7a3300a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/directives/public/for.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ module.exports = {
1313
if (inMatch) {
1414
var itMatch = inMatch[1].match(/\((.*),(.*)\)/)
1515
if (itMatch) {
16-
this.iterator = itMatch[1]
17-
this.alias = itMatch[2]
16+
this.iterator = itMatch[1].trim()
17+
this.alias = itMatch[2].trim()
1818
} else {
19-
this.alias = inMatch[1]
19+
this.alias = inMatch[1].trim()
2020
}
2121
this.expression = inMatch[2]
2222
}
@@ -98,6 +98,7 @@ module.exports = {
9898
var oldFrags = this.frags
9999
var frags = this.frags = new Array(data.length)
100100
var alias = this.alias
101+
var iterator = this.iterator
101102
var start = this.start
102103
var end = this.end
103104
var inDoc = _.inDoc(start)
@@ -121,6 +122,9 @@ module.exports = {
121122
// update $key
122123
if (key) {
123124
frag.scope.$key = key
125+
if (iterator) {
126+
frag.scope[iterator] = key
127+
}
124128
}
125129
// update data for track-by, object repeat &
126130
// primitive values.

0 commit comments

Comments
 (0)