ractivejs / ractive

Next-generation DOM manipulation
http://ractive.js.org
MIT License
5.94k stars 396 forks source link

is there any way to stop event propagation with event delegation on? #3298

Open LeJared opened 5 years ago

LeJared commented 5 years ago

Is there any way to stop event propagation with event delegation in iterative sections on?

fskreuz commented 5 years ago

Propagation should be stoppable via the usual means (stopPropagation, returning false). If it doesn't work, then it might be a bug.

Note that for delegated handlers, your event will have already bubbled from the target element (the actual element clicked) to the delegate element (the element holding the event handler). Stopping propagation from a delegate handler will only stop it from the delegate element upwards.

LeJared commented 5 years ago

I've fiddled around a little bit: https://jsfiddle.net/lejared/t0ydn94e/41/

stopPropagation doesn't work at all with event delegation on.

return false will stop event propagation within the iterative section but the event will still be fired outside.

When event delegation is disabled everything works as expected.

LeJared commented 5 years ago

I've done some more Testing: https://jsfiddle.net/lejared/t0ydn94e/47/

It seems like returning false within an iterative section with event delegation on also suppresses native js events for all nested elements, which are commonly used in decorators, thus making them stop working.

This is unexpected too and does not match the behavior of regular event propagation, when delegated events are turned off.