File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
packages/compiler-vapor/src/generators Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ export function genCreateComponent(
5353 const rawProps = context . withId ( ( ) => genRawProps ( props , context ) , ids )
5454 const inlineHandlers : CodeFragment [ ] = handlers . reduce < CodeFragment [ ] > (
5555 ( acc , { name, value } ) => {
56- const handler = genEventHandler ( context , value , false )
56+ // TODO should support .once modifier on component event
57+ const handler = genEventHandler ( context , value , undefined , false )
5758 return [ ...acc , `const ${ name } = ` , ...handler , NEWLINE ]
5859 } ,
5960 [ ] ,
Original file line number Diff line number Diff line change @@ -88,8 +88,9 @@ export function genEventHandler(
8888 nonKeys : string [ ]
8989 keys : string [ ]
9090 } = { nonKeys : [ ] , keys : [ ] } ,
91+ needWrap : boolean = true ,
9192) : CodeFragment [ ] {
92- let handlerExp : CodeFragment [ ] = [ `() => {}` ]
93+ let handlerExp : CodeFragment [ ] = [ `{}` ]
9394 if ( value && value . content . trim ( ) ) {
9495 const isMemberExp = isMemberExpression ( value , context . options )
9596 const isInlineStatement = ! (
@@ -117,7 +118,8 @@ export function genEventHandler(
117118 handlerExp = genWithModifiers ( context , handlerExp , nonKeys )
118119 if ( keys . length ) handlerExp = genWithKeys ( context , handlerExp , keys )
119120
120- return [ `() => ` , ...handlerExp ]
121+ if ( needWrap ) handlerExp . unshift ( `() => ` )
122+ return handlerExp
121123}
122124
123125function genWithModifiers (
You can’t perform that action at this time.
0 commit comments