@@ -24,21 +24,19 @@ export default function(babel) {
2424 return {
2525 inherits : syntaxJsx ,
2626 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+ } ,
4240 } ,
4341 } ,
4442 }
@@ -182,17 +180,12 @@ const addProp = (t, path, propName, expression, unshift = false) => {
182180 */
183181const genAssignmentCode = ( t , valuePath , valueExpression ) => {
184182 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+ ] )
196189 } else {
197190 return t . assignmentExpression ( '=' , valuePath . node , valueExpression )
198191 }
0 commit comments