I've come across an oddity while using Prototype to handle click events. If you click the button in the code below, it will trigger three alerts: 'Click 1', 'Click 2' and 'Click 3'. Modern browsers will invoke the listeners in the order they are registered in, while IE8 (and perhaps older IE versions as well) will invoke them in the opposite order. I find this odd because I thought Prototype maintained and executed a queue of listeners, which should be browser independent. Is this not so? If not, are event listeners supposed to be run in a certain order or are they asynchronous and thus their order irrelevant?
<button id="button">Click me</button>
<script type="text/javascript">
$('button').observe('click', function(event) {
alert('Click 1');
});
$('button').observe('click', function(event) {
alert('Click 2');
});
$('button').observe('click', function(event) {
alert('Click 3');
});
</script>