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

delegate #20

Open
akrymski opened this issue Dec 4, 2014 · 1 comment
Open

delegate #20

akrymski opened this issue Dec 4, 2014 · 1 comment

Comments

@akrymski
Copy link

akrymski commented Dec 4, 2014

Looking at your source it doesn't seem like delegation is done correctly: you can't just compare the event.target, you have to find the closest ancestor matching the selector.

This is how jQuery & Zepto do it, and that's the correct behaviour. Example:

$('body').delegate('li > a', 'click', fn);

If you've clicked a span within the a element then it won't match even though a child of the a element was indeed clicked.

Because of this requirement, firing delegated events is actually quite a bit slower, and is rarely a necessity. I've opted against them in espresso.js and have not had any issues at all.

@airblade
Copy link

This seems relevant: whatwg/dom#215.

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

2 participants