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

ElementEvents.subscribe set useCapture to true by default, which is not standard #657

Open
sebastien-roch opened this issue Feb 28, 2019 · 6 comments

Comments

@sebastien-roch
Copy link
Contributor

I'm submitting a bug report

  • Library Version:
    master

  • Language:
    all

Current behavior:
When using EventElements.subscribe, the listener will be set with useCapture = true, which is not the standard behavior of the native addEventListener() function and thus confuses the developer.

  • What is the expected behavior?
    EventElements.subscribe (and subscribeOnce) should use set useCapture to false by default.

  • What is the motivation / use case for changing the behavior?
    Mimic native API of the browser: addEventListener would set useCapture to false if not passed in arguments.

@bigopon
Copy link
Member

bigopon commented Feb 28, 2019

@sebastien-roch I've been hit by this as well. It's unfortunate, but we can only fix this in a major release of templating.

cc @EisenbergEffect

@EisenbergEffect
Copy link
Contributor

Sadly, we can't change it at this point because it could potentially break existing apps. What if we had some setting that could be set to get the desired behavior though, in a non-breaking way?

@bigopon
Copy link
Member

bigopon commented Mar 1, 2019

@EisenbergEffect We cna do that via a static field on ElementEvents class, say defaultListenerOptions

@EisenbergEffect
Copy link
Contributor

That works for me. @sebastien-roch Would you be interested in adding this property and updating the implementation to use it? I think it would make a fine contribution and we'd be very happy to work with you to get your PR in. Thoughts?

@sebastien-roch
Copy link
Contributor Author

I can do that. Towards which branch should I target my pull request having this defaultListenerOptions? I guess I have to create a second PR for a future breaking release where we just set capture to false by default.

@bigopon
Copy link
Member

bigopon commented Mar 14, 2019

@sebastien-roch Thanks for that. It should be develop branch

EisenbergEffect pushed a commit that referenced this issue Mar 19, 2019
…t default options when subscribing to events

ElementEvents.subscribe will set capture to true be default if not explicitely passed in argument. This is not the standard behavior of the native addEventListener() and confuses developers. This new options let you define the default behavior.

Fixes issue #657
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

3 participants