We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.1.1
https://jsfiddle.net/liyu1988/7pjdktvb/11/
test('.once', () => { const Foo = defineComponent({ render() {}, emits: { foo: null, bar: null }, created() { this.$emit('foo') this.$emit('foo') this.$emit('bar') this.$emit('bar') } }) const fn = jest.fn() const fn2 = jest.fn() render( h(Foo, { onFooOnce: fn, onBarOnce: fn2 }), nodeOps.createElement('div') ) document.createElement('#app') expect(fn).toHaveBeenCalledTimes(1) expect(fn2).toHaveBeenCalledTimes(2) // Should be equal to,this is 2 })
expect(fn2).toHaveBeenCalledTimes(1)
expect(fn2).toHaveBeenCalledTimes(2)
const onceHandler = props[handlerName `Once`] if (onceHandler) { if (!instance.emitted) { ;(instance.emitted = {} as Record<string, boolean>)[handlerName] = true } else if (instance.emitted[handlerName]) { return } // 初次执行once事件不会有问题,执行不同的once事件,则会重复执行,需要加上 instance.emitted[handlerName] = true callWithAsyncErrorHandling( onceHandler, instance, ErrorCodes.COMPONENT_EVENT_HANDLER, args ) }
The text was updated successfully, but these errors were encountered:
fix(runtime-core): fix multiple .once event handlers on same component (
011dee8
#3904) fix #3902
Successfully merging a pull request may close this issue.
Version
3.1.1
Reproduction link
https://jsfiddle.net/liyu1988/7pjdktvb/11/
Steps to reproduce
What is expected?
expect(fn2).toHaveBeenCalledTimes(1)
What is actually happening?
expect(fn2).toHaveBeenCalledTimes(2)
The text was updated successfully, but these errors were encountered: