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

I'd like to argue for formalizing [jQuery semantics](https://api.jquery.com/category/events/event-object/) as follows:
* `event.target`: "the object to which event is dispatched" (_no change_).
* `event.currentTarget`: "the object on event's propagation path for which callbacks are currently being invoked" (_generalizes the current definition¹ to a model with delegating_). Also used as the `this` context value for callbacks (_no change from 2.6 of **inner invoke** in [3.8. Dispatching events](https://dom.spec.whatwg.org/#dispatching-events)_).
* `event.delegateTarget`: "the object whose event listener’s callback is currently being invoked, equal to `event.currentTarget` when the event listener is not a delegate" (_new, text copied from current `event.currentTarget`_).

Doing so would preserve two important properties of the current model: equivalence of `currentTarget` with callback `this` context, and `currentTarget` tracking movement along the event path. I know from experience that both of those are often assumed in event handlers, and can't see how breaking them by essentially swapping the names of jQuery's precedent could lead to anything but confusion.

You can get a feel for things at [https://jsfiddle.net/yrk2pwky/](https://jsfiddle.net/yrk2pwky/), which also highlights the interesting edge case of a single event matched by the same delegate event listener at multiple points along its propagation path (for which I'm _not_ married to jQuery behavior).

¹ "[the object whose event listener’s callback is currently being invoked](https://dom.spec.whatwg.org/#interface-event)" in the current (non-delegating) model

---
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-213127012

Received on Thursday, 21 April 2016 21:50:45 UTC