Hi

I spent the last two days with a nasty problem
occurring with WebKit. If using JS in a multifile situation you can
easily observe (just put a debugger; or alert statement at the beginning of the file) that WebKit (Safari, Chrome) does NOT in order loading of given JS files, meaning you end up in a situation where JS code might sometimes run and sometimes fail dependent on server/local situations. I don't know where the WebKit guys got this crazy idea that evaluating JS source out of order might speed up things, but they clearly did it that way which is in my opinion violating the specs.

Solving the problem means you have to introduce a system of guaranteeing that code you depend on is loaded when the file in question is evaluated (see code below)

Werner

Assuming that a file yyy.js containing JS code injects a top level object with the filename yyy and is dependent on xxx.js:

//// code goes someplace early, like Application.js
modulesWaiting = {};

function moduleLoaded(module) {
  modulesWaiting[module] = null;
}

function waitForModules(module, f) {
  modulesWaiting[module] = f;
  for (var m in modulesWaiting) {
    if (modulesWaiting[m])
      modulesWaiting[m]();
  }
}

//// code of a single file yyy.js dependant on code in file xxx.js
waitForModules('yyy', function() {
  var deps = ['xxx'];  //comma separated list of modules
  var loaded = true;
  for (var i=0; i<deps.length; i++)
    loaded = loaded && (deps[i] != null);
  if (loaded) {
    //here comes the source, Luke
    //your source code

    yyy = {};          //signal readyness by defining this object
    moduleLoaded('yyy');
  }
});

<<attachment: werner.vcf>>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to