[Pkg-javascript-commits] [dojo] 23/87: backport [27773]; fixes #14459; !strict

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:15 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 72578b579c36696ac3bb4a1fbafec7e11177abfe
Author: Rawld Gill <rgill at altoviso.com>
Date:   Wed Feb 8 01:03:11 2012 +0000

    backport [27773]; fixes #14459; !strict
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.7/dojo@27781 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 _base/loader.js                                    | 27 ++++++-
 dojo.js                                            | 93 ++++++++++++----------
 tests/_base/loader/bootstrap.js                    |  4 +-
 .../loader/requirejs/relative/relative-tests.js    |  2 +-
 tests/_base/loader/requirejs/text/text.html        | 15 ++--
 5 files changed, 87 insertions(+), 54 deletions(-)

diff --git a/_base/loader.js b/_base/loader.js
index 4f22da5..be64ab1 100644
--- a/_base/loader.js
+++ b/_base/loader.js
@@ -35,9 +35,34 @@ define(["./kernel", "../has", "require", "module", "./json", "./lang", "./array"
 			checkDojoRequirePlugin();
 		},
 
+		touched,
+
+		traverse = function(m){
+			if(touched[m.mid] || /loadInit\!/.test(m.mid)){
+				// loadInit 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 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.
+				return true;
+			}
+		    touched[m.mid] = 1;
+			if(m.injected!==arrived && !m.executed){
+				return false;
+			}
+			for(var deps = m.deps || [], i= 0; i<deps.length; i++){
+				if(!traverse(deps[i])){
+					return false;
+				}
+			}
+			return true;
+		},
+
 		checkDojoRequirePlugin = function(){
+			touched = {};
 			dojoRequireModuleStack = array.filter(dojoRequireModuleStack, function(module){
-				return module.injected!==arrived && !module.executed;
+				return !traverse(module);
 			});
 			if(!dojoRequireModuleStack.length){
 				loaderVars.holdIdle();
diff --git a/dojo.js b/dojo.js
index 1d6c082..566211b 100644
--- a/dojo.js
+++ b/dojo.js
@@ -232,10 +232,7 @@
 		};
 
 		if(has("dom")){
-			// in legacy sync mode, the loader needs a minimal XHR library to load dojo/_base/loader and ojo/_base/xhr;
-			// when dojo/_base/loader pushes the sync loader machinery into the loader (via initSyncLoader), getText is
-			// replaced by dojo.getXhr() which allows for both sync and async op(and other features. It is not a problem
-			// depending on dojo for the sync loader since the sync loader will never be used without dojo.
+			// in legacy sync mode, the loader needs a minimal XHR library to load dojo/_base/loader and dojo/_base/xhr
 
 			var locationProtocol = location.protocol,
 				locationHost = location.host,
@@ -509,6 +506,7 @@
 						// "legacyAsync" => permanently in "xd" by choice
 						// "debugAtAllCosts" => trying to load everything via script injection (not implemented)
 						// otherwise, must be truthy => AMD
+						// legacyMode: sync | legacyAsync | xd | false
 						var mode = config[p];
 						req.legacyMode = legacyMode = (isString(mode) && /sync|legacyAsync/.test(mode) ? mode : (!mode ? "sync" : false));
 						req.async = !legacyMode;
@@ -576,11 +574,11 @@
 		// execute the various sniffs
 		//
 
-		if(has("dojo-sniff")){
-			for(var src, match, scripts = doc.getElementsByTagName("script"), i = 0; i < scripts.length && !match; i++){
+		if(has("dojo-cdn") || has("dojo-sniff")){
+			for(var dojoDir, src, match, scripts = doc.getElementsByTagName("script"), i = 0; i < scripts.length && !match; i++){
 				if((src = scripts[i].getAttribute("src")) && (match = src.match(/(.*)\/?dojo\.js(\W|$)/i))){
 					// if baseUrl wasn't explicitly set, set it here to the dojo directory; this is the 1.6- behavior
-					userConfig.baseUrl = userConfig.baseUrl || defaultConfig.baseUrl || match[1];
+					userConfig.baseUrl = dojoDir = userConfig.baseUrl || defaultConfig.baseUrl || match[1];
 
 					// see if there's a dojo configuration stuffed into the node
 					src = (scripts[i].getAttribute("data-dojo-config") || scripts[i].getAttribute("djConfig"));
@@ -612,6 +610,13 @@
 		config(defaultConfig, 1);
 		config(userConfig, 1);
 		config(dojoSniffConfig, 1);
+
+		if(has("dojo-cdn")){
+			packs.dojo.location = dojoDir;
+			packs.dijit.location = dojoDir + "../dijit/";
+			packs.dojox.location = dojoDir + "../dojox/";
+		}
+
 	}else{
 		// no config API, assume defaultConfig has everything the loader needs...for the entire lifetime of the application
 		paths = defaultConfig.paths;
@@ -683,43 +688,43 @@
 			if(isArray(a1)){
 				// signature is (requestList [,callback])
 
-				syntheticMid = "require*" + uid();
+					syntheticMid = "require*" + uid();
 
-				// resolve the request list with respect to the reference module
-				for(var mid, deps = [], i = 0; i < a1.length;){
-					mid = a1[i++];
-					if(mid in {exports:1, module:1}){
-						throw makeError("illegalModuleId", mid);
+					// resolve the request list with respect to the reference module
+					for(var mid, deps = [], i = 0; i < a1.length;){
+						mid = a1[i++];
+						if(mid in {exports:1, module:1}){
+							throw makeError("illegalModuleId", mid);
+						}
+						deps.push(getModule(mid, referenceModule));
 					}
-					deps.push(getModule(mid, referenceModule));
-				}
 
-				// construct a synthetic module to control execution of the requestList, and, optionally, callback
-				module = mix(makeModuleInfo("", syntheticMid, 0, ""), {
-					injected: arrived,
-					deps: deps,
-					def: a2 || noop,
-					require: referenceModule ? referenceModule.require : req
-				});
-				modules[module.mid] = module;
-
-				// checkComplete!=0 holds the idle signal; we're not idle if we're injecting dependencies
-				injectDependencies(module);
-
-				// try to immediately execute
-				// if already traversing a factory tree, then strict causes circular dependency to abort the execution; maybe
-				// it's possible to execute this require later after the current traversal completes and avoid the circular dependency.
-				// ...but *always* insist on immediate in synch mode
-				var strict = checkCompleteGuard && req.async;
-				checkCompleteGuard++;
-				execModule(module, strict);
-				checkIdle();
-				if(!module.executed){
-					// some deps weren't on board or circular dependency detected and strict; therefore, push into the execQ
-					execQ.push(module);
+					// construct a synthetic module to control execution of the requestList, and, optionally, callback
+					module = mix(makeModuleInfo("", syntheticMid, 0, ""), {
+						injected: arrived,
+						deps: deps,
+						def: a2 || noop,
+						require: referenceModule ? referenceModule.require : req
+					});
+					modules[module.mid] = module;
+
+					// checkComplete!=0 holds the idle signal; we're not idle if we're injecting dependencies
+					injectDependencies(module);
+
+					// try to immediately execute
+					// if already traversing a factory tree, then strict causes circular dependency to abort the execution; maybe
+					// it's possible to execute this require later after the current traversal completes and avoid the circular dependency.
+					// ...but *always* insist on immediate in synch mode
+					var strict = checkCompleteGuard && req.async;
+					checkCompleteGuard++;
+					execModule(module, strict);
+					checkIdle();
+					if(!module.executed){
+						// some deps weren't on board or circular dependency detected and strict; therefore, push into the execQ
+						execQ.push(module);
+					}
+					checkComplete();
 				}
-				checkComplete();
-			}
 			return contextRequire;
 		},
 
@@ -1320,13 +1325,13 @@
 				}
 				if(has("dojo-sync-loader") && legacyMode){
 					if(module.isXd){
-						// switch to async mode temporarily?
+						// switch to async mode temporarily; if current legacyMode!=sync, then is must be one of {legacyAsync, xd, false}
 						legacyMode==sync && (legacyMode = xd);
 						// fall through and load via script injection
 					}else if(module.isAmd && legacyMode!=sync){
 						// fall through and load via script injection
 					}else{
-						// mode may be sync, xd, or async; module may be AMD or legacy; but module is always located on the same domain
+						// mode may be sync, xd/legacyAsync, or async; module may be AMD or legacy; but module is always located on the same domain
 						var xhrCallback = function(text){
 							if(legacyMode==sync){
 								// the top of syncExecStack gives the current synchronously executing module; the loader needs
@@ -1484,8 +1489,8 @@
 		startTimer = function(){
 			clearTimer();
 			req.waitms && (timerId = setTimeout(function(){
-				clearTimer();
-				signal(error, makeError("timeout", waiting));
+					clearTimer();
+					signal(error, makeError("timeout", waiting));
 			}, req.waitms));
 		};
 	}
diff --git a/tests/_base/loader/bootstrap.js b/tests/_base/loader/bootstrap.js
index e439abb..f46a3ef 100644
--- a/tests/_base/loader/bootstrap.js
+++ b/tests/_base/loader/bootstrap.js
@@ -8,10 +8,10 @@ define(["dojo", "doh", "require"], function(dojo, doh, require){
 
 		function getText(t){
 			if(require.getText){
-				var text = require.getText(require.toUrl("dojo/tests/_base/loader/getText.txt"));
+				var text = require.getText(require.toUrl("dojo/tests/_base/loader/getText.txt")).replace(/\n/g, "");
 				t.assertEqual("dojo._getText() test data", text);
 				if(dojo._getText){
-					text = dojo._getText(require.toUrl("dojo/tests/_base/loader/getText.txt"));
+					text = dojo._getText(require.toUrl("dojo/tests/_base/loader/getText.txt")).replace(/\n/g, "");
 					t.assertEqual("dojo._getText() test data", text);
 				}
 			}
diff --git a/tests/_base/loader/requirejs/relative/relative-tests.js b/tests/_base/loader/requirejs/relative/relative-tests.js
index af6a0ff..21684e2 100644
--- a/tests/_base/loader/requirejs/relative/relative-tests.js
+++ b/tests/_base/loader/requirejs/relative/relative-tests.js
@@ -13,7 +13,7 @@ require({
                     t.is("one", one.name);
                     t.is("two", one.twoName);
                     t.is("three", one.threeName);
-                    t.is("hello world", one.message);
+                    t.is("hello world", one.message.replace(/\n/g, ""));
                 }
             ]
         );
diff --git a/tests/_base/loader/requirejs/text/text.html b/tests/_base/loader/requirejs/text/text.html
index 0caf231..e396f3e 100644
--- a/tests/_base/loader/requirejs/text/text.html
+++ b/tests/_base/loader/requirejs/text/text.html
@@ -32,12 +32,15 @@
 	                "text",
 	                [
 	                    function text(t){
-	                        t.is("<span>Hello World!</span>", sampleText);
-	                        t.is('<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>', widget.template);
-	                        t.is('subwidget', widget.subWidgetName);
-	                        t.is('<div data-type="subwidget"><h1>This is a subwidget</h1></div>', widget.subWidgetTemplate);
-	                        t.is('<span>This! is template2</span>', widget.subWidgetTemplate2);
-	                        t.is('<h1>Local</h1>', local.localHtml);
+							function check(expected, actual){
+								t.is(expected, actual.replace(/\n/g, ""));
+							}
+	                        check("<span>Hello World!</span>", sampleText);
+	                        check('<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>', widget.template);
+	                        check('subwidget', widget.subWidgetName);
+	                        check('<div data-type="subwidget"><h1>This is a subwidget</h1></div>', widget.subWidgetTemplate);
+	                        check('<span>This! is template2</span>', widget.subWidgetTemplate2);
+	                        check('<h1>Local</h1>', local.localHtml);
 	                    }
 	                ]
 	            );

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