Custom event dispatching for proper events handlers firing order
Author: fabiospampinatoCreated Nov 20, 2018Updated Dec 15, 2019
Labelsbugwontfix
Current behavior
- Bind a delegate event handler to
#foo. - Bind a normal event handler to
#foo. - If
event.stopPropagation ()is called from the delegate event handler the normal event handler executes too.
Expected behavior
- We should more tightly control the event propagation logic:
- First event handlers bound to the target element should be fired.
- Then event handlers bound to the target element in a delegate fashion should be fired.
- Then event handlers bound to the parent of the target element should be fired.
- Then event handlers bound to the parent of target element in a delegate fashion should be fired.
- And so on...
- If at each step
event.stopPropagation ()is called we should stop.
This is quite tricky to do, and impossible to implement without custom dispatching logic.
It's unlikely that it will be properly fixed in the future as the required amount of changes is extensive, and as mentioned most of the times simply calling event.stopImmediatePropagation () from the delegate event handler should be enough, but this remains a bug nonetheless.
Source: fabiospampinato/cash