mootools/mootools-core — Issue #2212: IE's attachEvent, FF's addEventListener and Event fire order
Author: ibolmo
Created: 2012-01-19 07:37:45+00:00
State: open
Labels: bug, enhancement

(from [Lighthouse](https://mootools.lighthouseapp.com/projects/2706/tickets/35-ie-s-attachevent-ff-s-addeventlistener-and-event-fire-order))

IE 6/7 with attachEvent fires event reversed as they were attached. It's a common issue, not related to mootools. However, the Events class can handle it.

addEvent("domready",function () {
$("x").addEvent("click",function () { alert("1"); });
$("x").addEvent("click",function () { alert("2"); });
});

x
FF will alert 1, 2

IE will alert 2, 1

For custom events, it's obviously ok:

addEvent("domready",function () {
$("x").addEvent("custom",function () { alert("1"); });
$("x").addEvent("custom",function () { alert("2"); });
$("x").addEvent("click",function () { this.fireEvent("custom"); });
});

x
alert 1,2 for both browsers.

Though I'm not relying on the event order, it might affect stuff without noticing.