Closed keichinger closed 7 years ago
Thank you.
The cause of this problem is, that only the direct event source is checked, whether it matches the selector and it doesn't check anything in between. So in your example the triggering node is a nested node of your selector.
A fix would be something like modifying the delegate
event callback to expand the checks to something like this:
source
matches. If yes -> callbackclosest
with the given selector between *) the source
and the node
. If yes -> callback*) This is up for debate, whether this should trigger:
// Element.matches(element, ".element") === true
delegate(element, ".element", "click", () => console.log("ohai"));
trigger(element, "click");
or whether only real children should match the delegate.
Only real children trigger, as this is the common implementation and a sensible default. This is already implemented in master.
Reproducing
The following HTML is given:
Trying to capture
click
events usingon
is working as expected:Clicking either the
<a>
or the<strong>
is producing a print to the console. However, withlive
it doesn't work:Expected behaviour
The expected behaviour is that
live
should also be able to capture clicks on the nested<strong>
element so I don't have to explicitly click the<a>
and nothing else.