const Foo = defineComponent({
render() {},
emits: {
- foo: null
+ foo: null,
+ bar: null
},
created() {
this.$emit('foo')
this.$emit('foo')
+ this.$emit('bar')
+ this.$emit('bar')
}
})
const fn = jest.fn()
+ const barFn = jest.fn()
render(
h(Foo, {
- onFooOnce: fn
+ onFooOnce: fn,
+ onBarOnce: barFn
}),
nodeOps.createElement('div')
)
expect(fn).toHaveBeenCalledTimes(1)
+ expect(barFn).toHaveBeenCalledTimes(1)
})
test('.once with normal listener of the same name', () => {
const onceHandler = props[handlerName + `Once`]
if (onceHandler) {
if (!instance.emitted) {
- ;(instance.emitted = {} as Record<string, boolean>)[handlerName] = true
+ instance.emitted = {} as Record<any, boolean>
} else if (instance.emitted[handlerName]) {
return
}
+ instance.emitted[handlerName] = true
callWithAsyncErrorHandling(
onceHandler,
instance,