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

Thank you for the input, this is much appreciated. Let's see if I have understood it all with an example. Tree: `<a id=root> <b> <a id=2> <c> <a id=1/> ...`

Now I register a delegate listener on `#root` using `root.addEventListener("x", callback, { delegate: "a" })`. Then I dispatch an `x` event on `#1`. This means that `callback` is first invoked for `#1`, with `target` and `currentTarget` being `#1`, and `delegateTarget` being `#root`. Then `callback` is invoked for `#2`, with `target` being `#1`, `currentTarget` being `#2`, and `delegateTarget` being `#root`. Then it stops, since we only look at descendants and there are no more `a` descendants of `#root`.

This is a little more involved than using selectors to filter the target. Would be interesting to hear what @dominiccooney and @smaug---- et all think of that.

It also gives us two choices as to how they integrate with the existing model:

1. While going through the event path during the bubbling phase, also look at ancestor listeners that have "delegate" set and see if the specified selector matches the node in the event path.
2. While invoking a listener that has "delegate" set, during the bubbling phase, go through its corresponding "`currentTarget`"'s descendants on the event path in reverse order.

Neither seems really attractive to me.

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

Received on Sunday, 24 April 2016 15:07:34 UTC