Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#13784 closed defect (fixed)

lazy loading of dojo/dnd/Source via require results in uncaught exception

Reported by: Adam Peller Owned by: Rawld Gill
Priority: high Milestone: 1.7
Component: Loader Version: 1.6.1
Keywords: Cc: ykami
Blocked By: Blocking:

Description (last modified by Adam Peller)

Uncaught TypeError: Cannot read property 'Source' of undefined from AutoSource.js, line 3

the shim in Source.js loads compatibility code in a dojo.ready. If Source.js is loaded after page load, this executes immediately, resulting in a circular dependency. AutoSource extends Source, and Source hasn't finished loading yet. Is it as simple as putting the shim after the declare?

Attachments (1)

lazy.html (716 bytes) - added by bill 8 years ago.
test case

Download all attachments as: .zip

Change History (13)

comment:1 Changed 8 years ago by Adam Peller

Description: modified (diff)

comment:2 Changed 8 years ago by Adam Peller

Description: modified (diff)

comment:3 Changed 8 years ago by Adam Peller

Description: modified (diff)

comment:4 Changed 8 years ago by Adam Peller

Resolution: invalid
Status: newclosed

test case was invalid. the typo 'dojox' instead of 'dojo' caused the error. Still trying to find a case where the dojo.ready fires immediately.

comment:5 Changed 8 years ago by Adam Peller

Resolution: invalid
Status: closedreopened

ok, I think I got a real test case this time.

Changed 8 years ago by bill

Attachment: lazy.html added

test case

comment:6 Changed 8 years ago by bill

Owner: changed from bill to Rawld Gill
Status: reopenednew

Rawld, what do you think?

The problem only occurs when calling dojo.require() through eval().

But when using eval(), the require() call in dojo/dnd/Source.js executes immediately even though we are clearly in the middle of loading a module (and hence, not ready).

BTW, test case goes in dojo/tests/dnd

Last edited 8 years ago by bill (previous) (diff)

comment:7 Changed 8 years ago by bill

Cc: ykami added
Component: GeneralLoader

Problem is now also occurring in dojox/mobile/tests/test_iPhone-IconMulti.html, after clicking the "Calendar" button (to show the Calendar). Clicking that button calls

dojo["require"](s)

where s == "dijit.form.Calendar", which loads dijit/form/_FormWidget.js, and then the dojo.ready() callback in _FormWidget.js runs immediately, rather than waiting until _FormWidget.js itself has finished loading.

// Back compat w/1.6, remove for 2.0
if(dojo && dojo.ready && !dojo.isAsync){
  dojo.ready(0, function(){
    var requires = ["dijit/form/_FormValueWidget"];
    require(requires); // use indirection so modules not rolled into a build
  });
}

Calendar was changed recently in #13814 but ISTM that change is OK, and merely triggers this problem with the loader.

(Tested on FF5/mac.)

Last edited 8 years ago by bill (previous) (diff)

comment:8 Changed 8 years ago by Adam Peller

Priority: normalhigh

comment:9 Changed 8 years ago by Rawld Gill

Status: newassigned

comment:10 Changed 8 years ago by Rawld Gill

Resolution: fixed
Status: assignedclosed

In [26652]:

hold the idle state when immediately executing modules in legacy sync mode; fixes #13784; !strict

comment:11 Changed 8 years ago by ykami

Verified that dijit.Calendar can be loaded and instantiated dynamically. Thank you for fixing this.

comment:12 Changed 8 years ago by Adam Peller

...and Maqetta works great with this patch also. Thanks!

Note: See TracTickets for help on using tickets.