Skip to content

Custom event dispatching for proper events handlers firing order #238

@fabiospampinato

Description

@fabiospampinato

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions