File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ export function build(cons: Cons, optionBuilder: OptionBuilder) {
2828 const proRet = await ret
2929 this . $emit ( eventName , proRet )
3030 }
31- else {
31+ else if ( ret === undefined ) {
32+ this . $emit ( eventName )
33+ } else {
3234 this . $emit ( eventName , ret )
3335 }
3436 }
Original file line number Diff line number Diff line change 22import { expect } from 'chai' ;
33import 'mocha' ;
44import { Component , Emit , Base , toNative } from '../../dist'
5+ import { mount } from '@vue/test-utils' ;
56
67@Component
78class Comp extends Base {
@@ -25,6 +26,9 @@ class Comp extends Base {
2526 } )
2627 }
2728
29+ @Emit
30+ noReturn ( ) { }
31+
2832}
2933const CompContext = toNative ( Comp ) as any
3034
@@ -73,6 +77,11 @@ describe('decorator Emit',
7377 expect ( emitName ) . to . equal ( 'promiseEmit' )
7478 expect ( emitValue ) . to . equal ( 'promiseEmit value' )
7579 } )
80+ it ( 'has an empty array when emitting void' , ( ) => {
81+ const component = mount ( CompContext )
82+ component . vm . noReturn ( )
83+ expect ( component . emitted ( 'noReturn' ) ) . to . eql ( [ [ ] ] )
84+ } )
7685 }
7786)
7887export default { }
You can’t perform that action at this time.
0 commit comments