Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#10159 closed defect (fixed)

baseUrl not discovered on dynamic load of dojo

Reported by: Mike Wilson Owned by: James Burke
Priority: high Milestone: 1.4
Component: Loader Version: 1.3.2
Keywords: Cc:
Blocked By: Blocking:

Description

When adding Dojo after page load (through head.appendChild(script)) and running from source, dojo.require() fails because dojo.baseDir is undefined. Typically this results in a 404 on dojo._base.lang which is the first required() resource.

The bug is reproducable with the following example from http://docs.dojocampus.org/djConfig#id8:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <title></title>
  </head>
  <body>
    <script type="text/javascript">
      var djConfig = {
        afterOnLoad: true
      };
      window.onload = function(){
        var d = document.getElementsByTagName("head")[0].appendChild(document.createElement('script'));
        d.src = "dojo-1.3.2-src/dojo/dojo.js";
        d.type = "text/javascript";
      }
    </script>
  </body>
</html>

The bug applies both to 1.3.2 and HEAD.

Change History (6)

comment:1 Changed 10 years ago by Mike Wilson

After some investigation this seems to be caused by a bug that wipes out the document, including the "dojo.js" script tag. This is happening on SVN/dojo/dojo.js:210:

document.write("<scr"+"ipt type='text/javascript' src='"+tmps[x]+"'></scr"+"ipt>");

which is called even though djConfig.afterOnLoad has been specified. I'm assuming a script tag should be created and appended instead of writing to the document. I've tried that and it seems to work, but there are still problems, as a load callback specified in:

djConfig.addOnLoad = ...

isn't being called as it should.

comment:2 Changed 10 years ago by dante

Owner: changed from alex to James Burke

comment:3 Changed 10 years ago by James Burke

djConfig.afterOnLoad was not designed to work with a non-built dojo.js file. I just updated the dojocampus docs to add that to the djConfig.afterOnLoad section and will update the API docs in source now, then close out the ticket.

comment:4 Changed 10 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [20624]) Fixes #10159, djConfig.afterOnLoad only works with built dojo.js files, so noting it in the documentation. \!strict

comment:5 Changed 10 years ago by bill

Milestone: tbd1.4

comment:6 Changed 10 years ago by Mike Wilson

It would be a great usability aid (that saves analysis time) if a "source" Dojo would show an error message when it is supplied options only relevant for built versions. And adding this check to SVN/dojo/dojo.js would only increase the footprint of source versions, not built versions.

Note: See TracTickets for help on using tickets.