Re: [whatwg/dom] Event delegation via EventListenerOptions (#215)

I agree with @gibson042 as far as the targets go. It would introduce more confusion to redefine everything.

The rough implementation that @josh [mentions above](https://github.com/whatwg/dom/issues/215#issuecomment-208482387) is much simpler than what is happening in jQuery though. That can only execute the handler once in the subtree and that particular code as-is could execute on an element above the delegation point.

The jQuery implementation bubbles the event from the target element up to but not including the delegate point element and executes the handler for any matches it finds; there can be multiple matches along the path. For each match, the handler executes and has the opportunity to call `event.stopPropagation()` to prevent further bubbling up to (or beyond) the delegation point. jQuery only handles bubbling for historical reasons so it doesn't need to worry about the symmetry of capturing for delegation.

I don't know whether jQuery's more general implementation is required to handle a lot of use cases or not.


---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/215#issuecomment-213199412

Received on Friday, 22 April 2016 01:25:58 UTC