Login Register

dojo.addOnLoad inconsistency between IE6 and FF3

Steps to recreate:

1. Enter the following in Firebug and run:

dojo.require("dojox.xml.DomParser");

2. Now enter:

dojo.require("dojox.xml.DomParser");
dojo.addOnLoad(function() {
   alert("inside");
});
alert("outside");

3. The alert will display 'inside' and then 'outside'.

Repeat the same steps in IE6. I used the DebugBar console.
You will see that in IE alert will first display 'outside' and then 'inside'.
The order is reversed. Why this inconsistency? I tried release 1.1.1 and 1.2.1

Ticket

This is not a real bug.

...well...let me amend that. Looking through the source code, I'm finding that there's a couple of workarounds for specific environments--including AIR, Opera and IE--that require firing dojo.loaded() using a setTimeout, as opposed to executing it directly. This is why you're seeing a reversal in ordering.

As an aside, you really should not depend on the timing of things being fired using dojo.addOnLoad--you should only depend on the order in which you added things with addOnLoad, and even then it's not something you should really rely on (just like you can't really rely on the order in which DOMNodes are returned from something like getElementsByTagName).

I'm going to close out that bug as "won't fix"; the timing bugs in various browsers are more important to handle than order consistency with callback functions.