Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#13194 closed defect (worksforme)

xdomain loads never fire domReady

Reported by: Mark Wubben Owned by: Rawld Gill
Priority: high Milestone: 1.7
Component: General Version: 1.7.0b1
Keywords: Cc:
Blocked By: Blocking:

Description

We're serving our assets from a different domain than the main pages, even during development. In trunk, domReady never fires:

Test case:

<!doctype html>
<script src="http://assets.eqm/scripts/dojo/dojo.js"></script>
<script>
require(["dojo/domReady!"], function(){
  alert("Ready");
});
</script>

This works fine from assets.eqm, but fails on assets2.eqm (set up as a server alias, so serving the exact same file).

Change History (4)

comment:1 Changed 8 years ago by Rawld Gill

Status: newassigned

comment:2 Changed 8 years ago by Rawld Gill

Resolution: worksforme
Status: assignedclosed

You must use the built version of dojo to make that work. I tested that and could not duplicate.

Re the dev version, e.g., what's in trunk, the test case given above looks like an AMD application, but it's using the sync loader since it is not explicitly setting the config variable async to truthy. If you change to the async loader, it will work as expected. For example, loading the following from, e.g., http://localhost forces xdomain and does fire the alert (notice the data-dojo-config attribute)

<script data-dojo-config="async:1" src="http://192.168.1.14/dev/dtk/release/dojo/dojo/dojo.js"></script>
<script>
require(["dojo/domReady!"], function(){
  alert("Ready");
});
</script>

However, the expression given in your test case and my refinement will not work with the synchronous loader in an unbuilt version because that loader will get into a deadlock trying to load has! dependencies synchronously while the modules are arriving asynchronously (it may work sometimes, but it's pure chance). If you inspect require.waiting you'll see the has! modules the loader is waiting on.

You can achieve nearly the desired affect by restating as follows:

<script>
dojoConfig={
  addOnLoad:function(){ 
	alert("Ready"); 
  }
};
</script>
<script data-dojo-config="async:0" src="http://192.168.1.14/dev/dtk/release/dojo/dojo/dojo.js"></script>

Nevertheless, I did find an unrelated bug in dojo.addOnLoad config which I'm attaching to this ticket.

comment:3 Changed 8 years ago by Rawld Gill

(In [25485]) repaired error that dojoConfig.addOnLoad was being processed twice; refs #13194

comment:4 Changed 8 years ago by Mark Wubben

Re the dev version, e.g., what's in trunk, the test case given above looks like an AMD application, but it's using the sync loader since it is not explicitly setting the config variable async to truthy. If you change to the async loader, it will work as expected.

Indeed. Thanks!

Note: See TracTickets for help on using tickets.