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

Events are fired twice for onxxxx type of handlers #116

Closed
cibernox opened this issue Nov 6, 2015 · 1 comment
Closed

Events are fired twice for onxxxx type of handlers #116

cibernox opened this issue Nov 6, 2015 · 1 comment

Comments

@cibernox
Copy link
Contributor

cibernox commented Nov 6, 2015

I was writing an acceptance test for something that looks like this:

<div class="foo" onclick={{action "foo"}}>Click me</div>

Bad news came when I realized that click('.foo') was triggering the foo action twice, first with a jquery.event with type click and a second time shortly after with a native MouseEvent.

Digging into the helper first and the addon later I've discover that the cause is that jquery's trigger triggers a jquery.event first, and if preventDefault is not called on that event, it fires a native event just afterwards, leading to unexpected behaviour (in my case, toggling a property twice and therefore letting it unchanged).

In real life the same code works perfectly because native events are fired instead.

I don't know if kebab actions, that will also receive native events, can be affected by this too.

Solutions I see:

A) Fire real events instead. Would it be backwards incompatible? I guess that the dispatcher would catch them and turn them into jquery events as it does with regular events in real life, and also mimics real behaviour better.

B) Accept a second argument in helpers click('.css-selector', { native: true }). Clearly backwards compatible, but leaves us with 2 different paths for firing events.

Thoughts?

@cibernox
Copy link
Contributor Author

cibernox commented Nov 6, 2015

LOL.

Closing this issue since this is wrong repo. Sorry for the noise 😭

@cibernox cibernox closed this as completed Nov 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant