[Pkg-javascript-commits] [dojo] 43/87: backport [28848]; refs #15491; !strict
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:39:19 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag 1.7.5
in repository dojo.
commit b434e8b18c65a9b35e4a23a733898c11dc67f897
Author: Rawld Gill <rgill at altoviso.com>
Date: Thu Jun 14 06:05:50 2012 +0000
backport [28848]; refs #15491; !strict
git-svn-id: http://svn.dojotoolkit.org/src/branches/1.7/dojo@28849 560b804f-0ae3-0310-86f3-f6aa0a117693
---
_base/loader.js | 67 ++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 42 insertions(+), 25 deletions(-)
diff --git a/_base/loader.js b/_base/loader.js
index 83b76d4..d85634c 100644
--- a/_base/loader.js
+++ b/_base/loader.js
@@ -42,10 +42,10 @@ define(["./kernel", "../has", "require", "module", "./json", "./lang", "./array"
//
// The algorithm works by traversing the dependency graphs (remember, there can be cycles so they are not trees)
// of each module in the dojoRequireModuleStack array (which contains the list of modules demanded by dojo/require!).
- // The moment a single module is discovered that is missing, the algorithm gives up an indicates that not all
+ // The moment a single module is discovered that is missing, the algorithm gives up and indicates that not all
// modules are on board. dojo/loadInit! and dojo/require! are ignored because there dependencies are inserted
// directly in dojoRequireModuleStack. For example, if "your/module" module depends on "dojo/require!my/module", then
- // *both* "dojo/require!my/module" and "my/module" will be in dojoRequireModuleStack. Obviously, if "dojo/require!my/module"
+ // *both* "dojo/require!my/module" and "my/module" will be in dojoRequireModuleStack. Obviously, if "my/module"
// is on board, then "dojo/require!my/module" is also satisfied, so the algorithm doesn't check for "dojo/require!my/module".
//
// Note: inserting a dojo/require!<some-module-list> dependency in the dojoRequireModuleStack achieves nothing
@@ -63,37 +63,54 @@ define(["./kernel", "../has", "require", "module", "./json", "./lang", "./array"
touched,
traverse = function(m){
- if(touched[m.mid]===1 || /loadInit\!/.test(m.mid) || /require\!/.test(m.mid)){
- // loadInit/require plugin modules are dependencies of modules in dojoRequireModuleStack...
- // which would cause a circular dependency chain that would never be resolved if checked here
- // notice all dependencies of any particular loadInit/require plugin module will already
- // be checked since those are pushed into dojoRequireModuleStack explicitly by the
- // plugin...so if a particular loadInitPlugin module's dependencies are not really
- // on board, that *will* be detected elsewhere in the traversal.
-
- // short curcuit the regexs to help performance
- touched[m.mid] = 1;
- return true;
- }
- if(touched[m.mid]===0 || (m.injected!==arrived && !m.executed)){
- touched[m.mid] = 0;
- return false;
- }
touched[m.mid] = 1;
- for(var deps = m.deps || [], i= 0; i<deps.length; i++){
- if(!traverse(deps[i])){
- touched[m.mid] = 0;
- return false;
+ for(var t, module, deps = m.deps || [], i= 0; i<deps.length; i++){
+ module = deps[i];
+ if(!(t = touched[module.mid])){
+ if(t===0 || !traverse(module)){
+ touched[m.mid] = 0;
+ return false;
+ }
}
}
return true;
},
checkDojoRequirePlugin = function(){
+ // initialize the touched hash with easy-to-compute values that help short circuit recursive algorithm;
+ // recall loadInit/require plugin modules are dependencies of modules in dojoRequireModuleStack...
+ // which would cause a circular dependency chain that would never be resolved if checked here
+ // notice all dependencies of any particular loadInit/require plugin module will already
+ // be checked since those are pushed into dojoRequireModuleStack explicitly by the
+ // plugin...so if a particular loadInitPlugin module's dependencies are not really
+ // on board, that *will* be detected elsewhere in the traversal.
+ var module, mid;
touched = {};
- for(var i = 0, end = dojoRequireModuleStack.length; i<end; i++){
- if(!traverse(dojoRequireModuleStack[i])){
- return;
+ for(mid in modules){
+ module = modules[mid];
+ // this could be improved by remembering the result of the regex tests
+ if(module.executed || module.noReqPluginCheck){
+ touched[mid] = 1;
+ }else{
+ if(module.noReqPluginCheck!==0){
+ // tag the module as either a loadInit or require plugin or not for future reference
+ module.noReqPluginCheck = /loadInit\!/.test(mid) || /require\!/.test(mid) ? 1 : 0;
+ }
+ if(module.noReqPluginCheck){
+ touched[mid] = 1;
+ }else if(module.injected!==arrived){
+ // not executed, has not arrived, and is not a loadInit or require plugin resource
+ touched[mid] = 0;
+ }// else, leave undefined and we'll traverse the dependencies
+ }
+ }
+
+ for(var t, i = 0, end = dojoRequireModuleStack.length; i<end; i++){
+ module = dojoRequireModuleStack[i];
+ if(!(t = touched[module.mid])){
+ if(t===0 || !traverse(module)){
+ return;
+ }
}
}
loaderVars.holdIdle();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git
More information about the Pkg-javascript-commits
mailing list