gator
gator copied to clipboard
stopPropagation does not stop propagation to listeners added with Gator
Basically, calling stopPropagation should prevent other delegated listeners further up the DOM from being called, but it doesn't. See the Fiddle here.
Furthermore, listeners added with addEventListener are still called because the actual call to stopPropagation happens at the level of the root element, stopping propagation above it, but not above the child element where the user called stopPropagation at, see this Fiddle for an example. This is non-trivial to solve, so it should at least be documented. Note that jQuery exhibits the same behavior (but does correctly stop propagation to other listeners added further up the DOM).
I didn't look too closely at the fiddle, but this is definitely a use case I tested when building Gator. We use it in places on the vimeo player too. Is this something specific to do with mixing Gator listeners with regular listeners? I am pretty sure if you apply all with Gator it works correctly.
I'm afraid not, here's a version of the Fiddle without regular listeners.
I updated the original Fiddle links in the issue body to be a little more clear.
Okay, so it seems it is actually dependent on the order the events are bound.
I updated the jsfiddle: http://jsfiddle.net/920fLt1d/9/ (you have to click the inner square now).
You can see it is working there as long as you bind the less specific events later on. Obviously that is not ideal. I'm going to see if there is an easy way to handle this internally.
Ah interesting. Yeah, the behavior is incorrect regardless, order should not matter in this scenario. It should be a quick fix, I just wanted to report it so it's tracked. Cheers!