@@ -24,21 +24,19 @@ export default function(babel) {
24
24
return {
25
25
inherits : syntaxJsx ,
26
26
visitor : {
27
- Program ( path ) {
28
- path . traverse ( {
29
- JSXAttribute ( path ) {
30
- const parsed = parseVModel ( t , path )
31
- if ( ! parsed ) {
32
- return
33
- }
34
-
35
- const { modifiers, valuePath } = parsed
36
-
37
- const parent = path . parentPath
38
- transformModel ( t , parent , valuePath , modifiers )
39
- path . remove ( )
40
- } ,
41
- } )
27
+ JSXAttribute : {
28
+ exit ( path ) {
29
+ const parsed = parseVModel ( t , path )
30
+ if ( ! parsed ) {
31
+ return
32
+ }
33
+
34
+ const { modifiers, valuePath } = parsed
35
+
36
+ const parent = path . parentPath
37
+ transformModel ( t , parent , valuePath , modifiers )
38
+ path . remove ( )
39
+ } ,
42
40
} ,
43
41
} ,
44
42
}
@@ -182,17 +180,12 @@ const addProp = (t, path, propName, expression, unshift = false) => {
182
180
*/
183
181
const genAssignmentCode = ( t , valuePath , valueExpression ) => {
184
182
let obj
185
- if ( t . isMemberExpression ( valuePath ) && ! t . isThisExpression ( obj = valuePath . get ( 'object' ) . node ) ) {
186
- return t . callExpression (
187
- t . memberExpression ( t . thisExpression ( ) , t . identifier ( '$set' ) ) ,
188
- [
189
- obj ,
190
- valuePath . node . computed
191
- ? valuePath . get ( 'property' ) . node
192
- : t . stringLiteral ( valuePath . get ( 'property.name' ) . node ) ,
193
- valueExpression
194
- ]
195
- ) ;
183
+ if ( t . isMemberExpression ( valuePath ) && ! t . isThisExpression ( ( obj = valuePath . get ( 'object' ) . node ) ) ) {
184
+ return t . callExpression ( t . memberExpression ( t . thisExpression ( ) , t . identifier ( '$set' ) ) , [
185
+ obj ,
186
+ valuePath . node . computed ? valuePath . get ( 'property' ) . node : t . stringLiteral ( valuePath . get ( 'property.name' ) . node ) ,
187
+ valueExpression ,
188
+ ] )
196
189
} else {
197
190
return t . assignmentExpression ( '=' , valuePath . node , valueExpression )
198
191
}
0 commit comments