@@ -36,8 +36,13 @@ function genFor (el, exp) {
36
36
}
37
37
const alias = inMatch [ 1 ] . trim ( )
38
38
exp = inMatch [ 2 ] . trim ( )
39
- const key = el . attrsMap [ 'track-by' ] || 'undefined'
40
- return `(${ exp } ).map(function (${ alias } , $index) {return ${ genElement ( el , key ) } })`
39
+ let key = getAttr ( el , 'track-by' )
40
+ if ( ! key ) {
41
+ key = 'undefined'
42
+ } else if ( key !== '$index' ) {
43
+ key = alias + '["' + key + '"]'
44
+ }
45
+ return `(${ exp } ).map(function (${ alias } , $index) {return ${ genElement ( el , key ) } })`
41
46
}
42
47
43
48
function genData ( el , key ) {
@@ -48,11 +53,13 @@ function genData (el, key) {
48
53
if ( key ) {
49
54
data += `key:${ key } ,`
50
55
}
51
- if ( el . attrsMap [ ':class' ] ) {
52
- data += `class: ${ el . attrsMap [ ':class' ] } ,`
56
+ const classBinding = getAttr ( el , ':class' ) || getAttr ( el , 'v-bind:class' )
57
+ if ( classBinding ) {
58
+ data += `class: ${ classBinding } ,`
53
59
}
54
- if ( el . attrsMap [ 'class' ] ) {
55
- data += `staticClass: "${ el . attrsMap [ 'class' ] } "`
60
+ const staticClass = getAttr ( el , 'class' )
61
+ if ( staticClass ) {
62
+ data += `staticClass: "${ staticClass } ",`
56
63
}
57
64
let attrs = `attrs:{`
58
65
let props = `props:{`
@@ -66,9 +73,7 @@ function genData (el, key) {
66
73
let value = attr . value
67
74
if ( bindRE . test ( name ) ) {
68
75
name = name . replace ( bindRE , '' )
69
- if ( name === 'class' ) {
70
- continue
71
- } else if ( name === 'style' ) {
76
+ if ( name === 'style' ) {
72
77
data += `style: ${ value } ,`
73
78
} else if ( mustUsePropsRE . test ( name ) ) {
74
79
hasProps = true
@@ -88,7 +93,7 @@ function genData (el, key) {
88
93
addHandler ( events , 'input' , `${ value } =$event.target.value` )
89
94
} else if ( dirRE . test ( name ) ) {
90
95
// TODO: normal directives
91
- } else if ( name !== 'class' ) {
96
+ } else {
92
97
hasAttrs = true
93
98
attrs += `"${ name } ": (${ JSON . stringify ( attr . value ) } ),`
94
99
}
0 commit comments