@@ -24,10 +24,9 @@ export function* generateElementEvents(
2424 for ( const prop of node . props ) {
2525 if (
2626 prop . type === CompilerDOM . NodeTypes . DIRECTIVE
27- && (
28- prop . name === 'on' && ( prop . arg ?. type === CompilerDOM . NodeTypes . SIMPLE_EXPRESSION && prop . arg . isStatic )
29- || prop . name === 'model' && ( ! prop . arg || prop . arg . type === CompilerDOM . NodeTypes . SIMPLE_EXPRESSION && prop . arg . isStatic )
30- )
27+ && prop . name === 'on'
28+ && prop . arg ?. type === CompilerDOM . NodeTypes . SIMPLE_EXPRESSION
29+ && prop . arg . isStatic
3130 ) {
3231 ctx . currentComponent ! . used = true ;
3332 if ( ! emitVar ) {
@@ -38,33 +37,21 @@ export function* generateElementEvents(
3837 yield `let ${ eventsVar } !: __VLS_NormalizeEmits<typeof ${ emitVar } >${ endOfLine } ` ;
3938 yield `let ${ propsVar } !: __VLS_FunctionalComponentProps<typeof ${ componentFunctionalVar } , typeof ${ componentVNodeVar } >${ endOfLine } ` ;
4039 }
41-
42- let source = prop . arg ?. loc . source ?? 'model-value' ;
43- let start = prop . arg ?. loc . start . offset ;
44- let propPrefix = 'on-' ;
40+ let source = prop . arg . loc . source ;
41+ let start = prop . arg . loc . start . offset ;
42+ let propPrefix = 'on' ;
4543 let emitPrefix = '' ;
46- if ( prop . name === 'model' ) {
47- propPrefix = 'onUpdate:' ;
48- emitPrefix = 'update:' ;
49- }
50- else if ( source . startsWith ( 'vue:' ) ) {
44+ if ( source . startsWith ( 'vue:' ) ) {
5145 source = source . slice ( 'vue:' . length ) ;
52- start = start ! + 'vue:' . length ;
53- propPrefix = 'onVnode- ' ;
46+ start = start + 'vue:' . length ;
47+ propPrefix = 'onVnode' ;
5448 emitPrefix = 'vnode-' ;
5549 }
56-
57- yield `(): __VLS_NormalizeComponentEvent<typeof ${ propsVar } , typeof ${ eventsVar } , '${ camelize ( propPrefix + source ) } ', '${ emitPrefix + source } ', '${ camelize ( emitPrefix + source ) } '> => ({${ newLine } ` ;
58- if ( prop . name === 'on' ) {
59- yield * generateEventArg ( ctx , source , start ! , propPrefix . slice ( 0 , - 1 ) ) ;
60- yield `: ` ;
61- yield * generateEventExpression ( options , ctx , prop ) ;
62- }
63- else {
64- yield `'${ camelize ( propPrefix + source ) } ': ` ;
65- yield * generateModelEventExpression ( options , ctx , prop ) ;
66- }
67- yield `})${ endOfLine } ` ;
50+ yield `const ${ ctx . getInternalVariable ( ) } : __VLS_NormalizeComponentEvent<typeof ${ propsVar } , typeof ${ eventsVar } , '${ camelize ( propPrefix + '-' + source ) } ', '${ emitPrefix } ${ source } ', '${ camelize ( emitPrefix + source ) } '> = {${ newLine } ` ;
51+ yield * generateEventArg ( ctx , source , start , propPrefix ) ;
52+ yield `: ` ;
53+ yield * generateEventExpression ( options , ctx , prop ) ;
54+ yield `}${ endOfLine } ` ;
6855 }
6956 }
7057}
@@ -172,29 +159,6 @@ export function* generateEventExpression(
172159 }
173160}
174161
175- export function * generateModelEventExpression (
176- options : TemplateCodegenOptions ,
177- ctx : TemplateCodegenContext ,
178- prop : CompilerDOM . DirectiveNode
179- ) : Generator < Code > {
180- if ( prop . exp ?. type === CompilerDOM . NodeTypes . SIMPLE_EXPRESSION ) {
181- yield `(...[$event]) => (` ;
182- yield * generateInterpolation (
183- options ,
184- ctx ,
185- 'template' ,
186- ctx . codeFeatures . verification ,
187- prop . exp . content ,
188- prop . exp . loc . start . offset ,
189- prop . exp . loc
190- ) ;
191- yield ` = $event)` ;
192- }
193- else {
194- yield `() => {}` ;
195- }
196- }
197-
198162export function isCompoundExpression ( ts : typeof import ( 'typescript' ) , ast : ts . SourceFile ) {
199163 let result = true ;
200164 if ( ast . statements . length === 0 ) {
0 commit comments