Does Events Handlers in JavaScript for one event fired as FIFO, LIFO or in parallel?
views:
83answers:
3
A:
PPK has an excellent writeup on Event bubbling and Event Capturing.
Thiyagaraj
2009-10-10 15:50:43
+3
A:
It's very simple. DOM Level 2 Events module does not specify order in which event listeners are to be fired. However, DOM Level 3 Events module does specify order to be the same as registration one.
First registered — first fired.
Note that DOM Level 3 Events module is still a draft, whereas Level 2 one is a recommendation. Nevertheless, modern browsers often follow semantics of exactly this draft Level 3 specification, instead of an older Level 2 one.
In practice, IIRC, only IE doesn't respect order of event listeners. All other browsers implement it as FIFO (and as described in DOM L3 Events). You can also find related tests online :)
kangax
2009-10-11 06:57:08
Nice references.
Crescent Fresh
2009-10-12 04:07:19
Indeed I seriously hate IE8 right now because it's executing my events in REVERSE order relative to every other browser on the planet *including* IE7. Grr.
LRE
2010-03-23 20:56:37