[Pkg-javascript-commits] [dojo] 22/88: backport [29688]; fixes #15952; !strict

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:32 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.8.5
in repository dojo.

commit ffad2fa46ba249cf388e5ddbc98fd49de7442788
Author: Rawld Gill <rgill at altoviso.com>
Date:   Fri Sep 21 17:12:31 2012 +0000

    backport [29688]; fixes #15952; !strict
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.8/dojo@29689 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 dojo.js                                            | 36 +++++++++++++++-------
 .../config/someModuleConfiggedPriorToBoot.js       |  5 +++
 tests/_base/loader/config/test.html                |  7 ++++-
 3 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/dojo.js b/dojo.js
index 70e37a4..0e6f36b 100644
--- a/dojo.js
+++ b/dojo.js
@@ -117,9 +117,9 @@
 
 		// this will be the global require function; define it immediately so we can start hanging things off of it
 		req = function(
-			config,       //(object, optional) hash of configuration properties
+			config,		  //(object, optional) hash of configuration properties
 			dependencies, //(array of commonjs.moduleId, optional) list of modules to be loaded before applying callback
-			callback      //(function, optional) lamda expression to apply to module values implied by dependencies
+			callback	  //(function, optional) lamda expression to apply to module values implied by dependencies
 		){
 			return contextRequire(config, dependencies, callback, 0, req);
 		},
@@ -394,14 +394,14 @@
 			// Modules go through several phases in creation:
 			//
 			// 1. Requested: some other module's definition or a require application contained the requested module in
-			//    its dependency vector or executing code explicitly demands a module via req.require.
+			//	  its dependency vector or executing code explicitly demands a module via req.require.
 			//
 			// 2. Injected: a script element has been appended to the insert-point element demanding the resource implied by the URL
 			//
 			// 3. Loaded: the resource injected in [2] has been evalated.
 			//
 			// 4. Defined: the resource contained a define statement that advised the loader about the module. Notice that some
-			//    resources may just contain a bundle of code and never formally define a module via define
+			//	  resources may just contain a bundle of code and never formally define a module via define
 			//
 			// 5. Evaluated: the module was defined via define and the loader has evaluated the factory and computed a result.
 			= {},
@@ -510,6 +510,14 @@
 				packs[name] = packageInfo;
 			},
 
+			delayedModuleConfig
+				// module config cannot be consummed until the loader is completely initialized; therefore, all
+				// module config detected during booting is memorized and applied at the end of loader initialization
+				// TODO: this is a bit of a kludge; all config should be moved to end of loader initialization, but
+				// we'll delay this chore and do it with a final loader 1.x cleanup after the 2.x loader prototyping is complete
+				= [],
+
+
 			config = function(config, booting, referenceModule){
 				for(var p in config){
 					if(p=="waitSeconds"){
@@ -593,9 +601,13 @@
 					aliases.push(pair);
 				});
 
-				for(p in config.config){
-					var module = getModule(p, referenceModule);
-					module.config = mix(module.config || {}, config.config[p]);
+				if(booting){
+					delayedModuleConfig.push({config:config.config});
+				}else{
+					for(p in config.config){
+						var module = getModule(p, referenceModule);
+						module.config = mix(module.config || {}, config.config[p]);
+					}
 				}
 
 				// push in any new cache values
@@ -929,6 +941,7 @@
 				}
 				mapItem = mapItem || mapProgs.star;
 				mapItem = mapItem && runMapProg(mid, mapItem[1]);
+
 				if(mapItem){
 					mid = mapItem[1] + mid.substring(mapItem[3]);
 					}
@@ -1155,9 +1168,9 @@
 				}
 			}
 			// delete references to synthetic modules
-	        if (/^require\*/.test(module.mid)) {
-	            delete modules[module.mid];
-	        }
+			if (/^require\*/.test(module.mid)) {
+				delete modules[module.mid];
+			}
 		},
 
 		circleTrace = [],
@@ -1873,7 +1886,8 @@
 	}
 
 	if(has("dojo-config-api")){
-		var bootDeps = dojoSniffConfig.deps ||  userConfig.deps || defaultConfig.deps,
+		forEach(delayedModuleConfig, function(c){ config(c); });
+		var bootDeps = dojoSniffConfig.deps ||	userConfig.deps || defaultConfig.deps,
 			bootCallback = dojoSniffConfig.callback || userConfig.callback || defaultConfig.callback;
 		req.boot = (bootDeps || bootCallback) ? [bootDeps || [], bootCallback] : 0;
 	}
diff --git a/tests/_base/loader/config/someModuleConfiggedPriorToBoot.js b/tests/_base/loader/config/someModuleConfiggedPriorToBoot.js
new file mode 100644
index 0000000..4fcde73
--- /dev/null
+++ b/tests/_base/loader/config/someModuleConfiggedPriorToBoot.js
@@ -0,0 +1,5 @@
+define(["module"], function(module){
+	return {
+		getConfig:function(){return module.config();}
+	};
+});
diff --git a/tests/_base/loader/config/test.html b/tests/_base/loader/config/test.html
index 21ac326..793d7f6 100644
--- a/tests/_base/loader/config/test.html
+++ b/tests/_base/loader/config/test.html
@@ -35,6 +35,9 @@
 				name:"doh",
 				location:"util/doh"
 			}],
+			config:{
+				"loader/someModuleConfiggedPriorToBoot":{someConfig:"this is the config for someModuleConfiggedPriorToBoot"}
+			},
 			deps:["doh"],
 			callback:function(doh){
 				var master = new doh.Deferred(), waiting = 2;
@@ -58,7 +61,9 @@
 					"pkgMapped/m1":{globalConfig:"globalConfigForpkgMapped/m1", isMapped:true},
 					"pkgMapped/m2":{globalConfig:"globalConfigForpkgMapped/m2"}
 				}});
-				require(["loader/someModule"], function(someModule){
+				require(["loader/someModuleConfiggedPriorToBoot", "loader/someModule"], function(someModuleConfiggedPriorToBoot, someModule){
+					doh.is(someModuleConfiggedPriorToBoot.getConfig(), {
+						someConfig:"this is the config for someModuleConfiggedPriorToBoot"});
 					doh.is(someModule.getConfig(), {
 						someConfig:"this is the config for someModule-someConfig"});
 					doh.is(someModule.m1.getConfig(), {

-- 
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