File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,20 @@ export function build(cons: Cons, optionBuilder: OptionBuilder) {
26
26
optionBuilder . computed ??= { }
27
27
const slot = obtainSlot ( cons . prototype )
28
28
const names = slot . obtainMap ( 'v-model' ) !
29
+ const emits = slot . obtainMap ( 'emits' )
29
30
if ( names && names . size > 0 ) {
30
31
names . forEach ( ( value , name ) => {
31
32
const vmodelName = ( value && value . name ) ?? 'modelValue'
33
+ const eventName = `update:${ vmodelName } `
32
34
optionBuilder . computed ! [ name ] = {
33
35
get : function ( this : any ) {
34
36
return this [ vmodelName ]
35
37
} ,
36
38
set : function ( val : any ) {
37
- this . $emit ( `update: ${ vmodelName } ` , val )
39
+ this . $emit ( eventName , val )
38
40
}
39
41
}
42
+ emits . set ( eventName , true )
40
43
} )
41
44
}
42
45
}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export class Comp extends Base {
17
17
}
18
18
const CompContext = Comp as any
19
19
20
- describe ( 'decorator Watch ' ,
20
+ describe ( 'decorator VModal ' ,
21
21
( ) => {
22
22
it ( 'default' , ( ) => {
23
23
expect ( 'object' ) . to . equal ( typeof CompContext . props )
@@ -27,6 +27,8 @@ describe('decorator Watch',
27
27
expect ( 'test' ) . to . equal ( CompContext . computed [ 'defaultValueAgent' ] . get . apply ( {
28
28
modelValue :'test'
29
29
} ) )
30
+
31
+ expect ( true ) . to . equal ( CompContext . emits . includes ( 'update:modelValue' ) )
30
32
CompContext . computed [ 'defaultValueAgent' ] . set . apply ( {
31
33
$emit ( name :string , value :any ) {
32
34
expect ( 'update:modelValue' ) . to . equal ( name )
@@ -42,6 +44,7 @@ describe('decorator Watch',
42
44
expect ( 'test' ) . to . equal ( CompContext . computed [ 'valueAgent' ] . get . apply ( {
43
45
value :'test'
44
46
} ) )
47
+ expect ( true ) . to . equal ( CompContext . emits . includes ( 'update:value' ) )
45
48
CompContext . computed [ 'valueAgent' ] . set . apply ( {
46
49
$emit ( name :string , value :any ) {
47
50
expect ( 'update:value' ) . to . equal ( name )
You can’t perform that action at this time.
0 commit comments