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) {
2626 optionBuilder . computed ??= { }
2727 const slot = obtainSlot ( cons . prototype )
2828 const names = slot . obtainMap ( 'v-model' ) !
29+ const emits = slot . obtainMap ( 'emits' )
2930 if ( names && names . size > 0 ) {
3031 names . forEach ( ( value , name ) => {
3132 const vmodelName = ( value && value . name ) ?? 'modelValue'
33+ const eventName = `update:${ vmodelName } `
3234 optionBuilder . computed ! [ name ] = {
3335 get : function ( this : any ) {
3436 return this [ vmodelName ]
3537 } ,
3638 set : function ( val : any ) {
37- this . $emit ( `update: ${ vmodelName } ` , val )
39+ this . $emit ( eventName , val )
3840 }
3941 }
42+ emits . set ( eventName , true )
4043 } )
4144 }
4245}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export class Comp extends Base {
1717}
1818const CompContext = Comp as any
1919
20- describe ( 'decorator Watch ' ,
20+ describe ( 'decorator VModal ' ,
2121 ( ) => {
2222 it ( 'default' , ( ) => {
2323 expect ( 'object' ) . to . equal ( typeof CompContext . props )
@@ -27,6 +27,8 @@ describe('decorator Watch',
2727 expect ( 'test' ) . to . equal ( CompContext . computed [ 'defaultValueAgent' ] . get . apply ( {
2828 modelValue :'test'
2929 } ) )
30+
31+ expect ( true ) . to . equal ( CompContext . emits . includes ( 'update:modelValue' ) )
3032 CompContext . computed [ 'defaultValueAgent' ] . set . apply ( {
3133 $emit ( name :string , value :any ) {
3234 expect ( 'update:modelValue' ) . to . equal ( name )
@@ -42,6 +44,7 @@ describe('decorator Watch',
4244 expect ( 'test' ) . to . equal ( CompContext . computed [ 'valueAgent' ] . get . apply ( {
4345 value :'test'
4446 } ) )
47+ expect ( true ) . to . equal ( CompContext . emits . includes ( 'update:value' ) )
4548 CompContext . computed [ 'valueAgent' ] . set . apply ( {
4649 $emit ( name :string , value :any ) {
4750 expect ( 'update:value' ) . to . equal ( name )
You can’t perform that action at this time.
0 commit comments