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

Projects
None yet
3 participants
@sebastien-roch
Copy link
Contributor

sebastien-roch commented Feb 28, 2019

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

EisenbergEffect commented Mar 1, 2019

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

This comment has been minimized.

Copy link
Member

bigopon commented Mar 1, 2019

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

@EisenbergEffect

This comment has been minimized.

Copy link
Member

EisenbergEffect commented Mar 1, 2019

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

This comment has been minimized.

Copy link
Contributor Author

sebastien-roch commented Mar 14, 2019

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

This comment has been minimized.

Copy link
Member

bigopon commented Mar 14, 2019

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

sebastien-roch pushed a commit to sebastien-roch/templating that referenced this issue Mar 18, 2019

sebastien-roch pushed a commit to sebastien-roch/templating that referenced this issue Mar 18, 2019

Sebastien Roch
fix(ElementEvents): ElementEvents.defaultListenerOptions allows to se…
…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 aurelia#657

sebastien-roch added a commit to sebastien-roch/templating that referenced this issue Mar 18, 2019

fix(ElementEvents): ElementEvents.defaultListenerOptions allows to se…
…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 aurelia#657

EisenbergEffect added a commit that referenced this issue Mar 19, 2019

fix(ElementEvents): ElementEvents.defaultListenerOptions allows to se…
…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
You can’t perform that action at this time.