@@ -24,10 +24,9 @@ export function* generateElementEvents(
24
24
for ( const prop of node . props ) {
25
25
if (
26
26
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
31
30
) {
32
31
ctx . currentComponent ! . used = true ;
33
32
if ( ! emitVar ) {
@@ -38,33 +37,21 @@ export function* generateElementEvents(
38
37
yield `let ${ eventsVar } !: __VLS_NormalizeEmits<typeof ${ emitVar } >${ endOfLine } ` ;
39
38
yield `let ${ propsVar } !: __VLS_FunctionalComponentProps<typeof ${ componentFunctionalVar } , typeof ${ componentVNodeVar } >${ endOfLine } ` ;
40
39
}
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' ;
45
43
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:' ) ) {
51
45
source = source . slice ( 'vue:' . length ) ;
52
- start = start ! + 'vue:' . length ;
53
- propPrefix = 'onVnode- ' ;
46
+ start = start + 'vue:' . length ;
47
+ propPrefix = 'onVnode' ;
54
48
emitPrefix = 'vnode-' ;
55
49
}
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 } ` ;
68
55
}
69
56
}
70
57
}
@@ -172,29 +159,6 @@ export function* generateEventExpression(
172
159
}
173
160
}
174
161
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
-
198
162
export function isCompoundExpression ( ts : typeof import ( 'typescript' ) , ast : ts . SourceFile ) {
199
163
let result = true ;
200
164
if ( ast . statements . length === 0 ) {
0 commit comments