Skip to content
New issue

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

.once modifier did'nt perform as expected if my event handler return null #11281

Open
LKL2017 opened this issue Apr 5, 2020 · 4 comments
Open

Comments

@LKL2017
Copy link

LKL2017 commented Apr 5, 2020

Version

2.6.11

Reproduction link

https://jsfiddle.net/q0v6m8dr/1/

Steps to reproduce

  1. bind a handler to an event which with a '.once' modifier
  2. set null for the hanlder's return value
  3. trigger the event, and trigger again

What is expected?

only the first trigger will invoke handler, under '.once' influence

What is actually happening?

subsequent trigger will also invoke handler beside the first one

@posva
Copy link
Member

posva commented Apr 5, 2020

I'm unsure about this one since the condition is explicitly stated at https://github.com/vuejs/vue/blob/dev/src/core/instance/events.js#L36 but I don't know if it's necessary.

@gebilaoxiong do you remember why you added the check for (res !== null) at #8036

@hulkyhawk
Copy link

hulkyhawk commented Apr 6, 2020

@posva when deal with native once event, there is a (res !== null) guard just to make sure the
.self modifier works. see the issure #4846.
but there is no such a problem when the event is component level, the problem should be solved maybe

@posva
Copy link
Member

posva commented Apr 6, 2020

Thanks @hulkyhawk, let's keep this open as the code could potentially be adapted to allow an event listener to return null when .once is added

@gebilaoxiong
Copy link
Member

gebilaoxiong commented Apr 19, 2020

@posva I'm sorry I didn't notice the news;

This is not a broken change,The logic used here is the old one:
https://github.com/vuejs/vue/pull/8036/files#diff-2b06abcad137617975c484105ce8f5a7L26-L28

It looks like a signal value, But I can not find the test-case;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants