diff --git a/src/vueWrapper.ts b/src/vueWrapper.ts index 467621b61..c6ceb4cbf 100644 --- a/src/vueWrapper.ts +++ b/src/vueWrapper.ts @@ -56,7 +56,15 @@ export class VueWrapper const vm = this.vm if (!vm) return - const emits = vm.$options.emits || [] + const emits = vm.$options.emits + ? // if emits is declared as an array + Array.isArray(vm.$options.emits) + ? // use it + vm.$options.emits + : // otherwise it's declared as an object + // and we only need the keys + Object.keys(vm.$options.emits) + : [] const element = this.element for (let eventName of Object.keys(eventTypes)) { // if a component includes events in 'emits' with the same name as native diff --git a/tests/emit.spec.ts b/tests/emit.spec.ts index e8ec397d8..9862a3a90 100644 --- a/tests/emit.spec.ts +++ b/tests/emit.spec.ts @@ -137,7 +137,9 @@ describe('emitted', () => { it('should not propagate child custom events', () => { const Child = defineComponent({ name: 'Child', - emits: ['hi'], + emits: { + hi: (foo: 'foo', bar: 'bar') => true + }, setup(props, { emit }) { return () => h('div', [h('button', { onClick: () => emit('hi', 'foo', 'bar') })])