Financial-Times / ftdomdelegate

Create and manage a DOM event delegator
MIT License
320 stars 36 forks source link

Event listener execution order is backwards when useCapture = true #64

Open lazd opened 10 years ago

lazd commented 10 years ago

It seems event listeners fire in the wrong order when useCapture = true. See this Fiddle.

With this markup:

<div id="node0">
  <div id="node1">
    <div id="node2">
    </div>
  </div>
</div>

And with listeners added on the capture phase:

var events = new domDelegate.Delegate(document.querySelector('#node0'));

events.on('click', handler0, true);

events.on('click', '#node1', handler1, true);

events.on('click', '#node2', handler2, true);

For an event triggered on #node2:

document.querySelector('#node2').click();

One would expect the following call order, which matches that of native event listeners.

Instead, we get:

orangemug commented 8 years ago

There is fix on branch https://github.com/ftlabs/ftdomdelegate/compare/master...orangemug:fix/issue-64

This continues on work from #73 ...which in turn is waiting on PR #81 (all the PR's!)