import { createObjectProperty , createSimpleExpression , } from '../ast' ; import { NodeTypes } from '../../shared/svu' ; export const transformOn = ( dir ) => { const { loc , arg } = dir ; let eventName ; if ( arg . type === NodeTypes . SIMPLE_EXPRESSION ) { if ( arg . isStatic ) { eventName = createSimpleExpression ( 'onClick' , true , arg . loc ) ; } } let exp = dir . exp ; if ( exp && ! exp . content . trim ( ) ) { exp = undefined ; } let ret = { props : [ createObjectProperty ( eventName , exp || createSimpleExpression ( `() => {}` , false , loc ) ) ] } ; return ret ; } ;