[Pkg-javascript-commits] [dojo] 07/28: Fix star mapping, aliasing, and pathing for built layers.

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


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

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

commit 9d5d0a6d24e8dc50709f4309f988f18f41154236
Author: Bryan Forbes <bryan at reigndropsfall.net>
Date:   Tue Nov 12 16:50:56 2013 -0600

    Fix star mapping, aliasing, and pathing for built layers.
    
    Fixes #17475
---
 dojo.js                         |  6 ++--
 tests/_base/loader.js           |  1 +
 tests/_base/loader/mapping.html | 77 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/dojo.js b/dojo.js
index d8e4980..37633f8 100644
--- a/dojo.js
+++ b/dojo.js
@@ -455,7 +455,7 @@
 					}else if(p=="*now"){
 						now = item;
 					}else if(p!="*noref"){
-						m = getModuleInfo(p, referenceModule);
+						m = getModuleInfo(p, referenceModule, true);
 						cache[m.mid] = cache[urlKeyPrefix + m.url] = item;
 					}
 				}
@@ -994,8 +994,8 @@
 			return makeModuleInfo(pid, mid, pack, compactPath(url));
 		},
 
-		getModuleInfo = function(mid, referenceModule){
-			return getModuleInfo_(mid, referenceModule, packs, modules, req.baseUrl, mapProgs, pathsMapProg);
+		getModuleInfo = function(mid, referenceModule, fromPendingCache){
+			return getModuleInfo_(mid, referenceModule, packs, modules, req.baseUrl, fromPendingCache ? [] : mapProgs, fromPendingCache ? [] : pathsMapProg);
 		},
 
 		resolvePluginResourceId = function(plugin, prid, referenceModule){
diff --git a/tests/_base/loader.js b/tests/_base/loader.js
index f8590f6..6fb0881 100644
--- a/tests/_base/loader.js
+++ b/tests/_base/loader.js
@@ -141,6 +141,7 @@ define([
 		doh.register("tests._base.loader.requirejs-exports-async", require.toUrl("./loader/requirejs/exports/exports.html"), {async:1});
 
 		doh.register("tests._base.loader.require-config", require.toUrl("./loader/config/test.html"), {async:1});
+		doh.register("tests._base.loader.mapping", require.toUrl("./loader/mapping.html"), {async:1});
 	}
 });
 
diff --git a/tests/_base/loader/mapping.html b/tests/_base/loader/mapping.html
new file mode 100644
index 0000000..0e56e4d
--- /dev/null
+++ b/tests/_base/loader/mapping.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+	<meta charset="utf-8">
+	<title>Dojo loader mapping after build test</title>
+</head>
+<body>
+	<script>
+		var dojoConfig = {
+			async: true,
+			map: {
+				'my/replacement/A': {
+					'my/A': 'my/A'
+				},
+				'*': {
+					'my/A': 'my/replacement/A'
+				}
+			}
+		};
+	</script>
+	<script src="../../../dojo.js"></script>
+	<script>
+		// simulate a built layer, this is added to dojo.js by the builder
+		require({
+			cache: {
+				'my/replacement/A': function () {
+					define([ '../A' ], function (A) {
+						return { it: 'is a replacement module' };
+					});
+				},
+				'my/A': function () {
+					define([ './B' ], function (B) {
+						return { it: 'is the original module' };
+					});
+				},
+				'my/B': function () {
+					define([], function () {
+						return { it: 'is a module dependency' };
+					});
+				}
+			}
+		});
+		// consume pending cache, the following are added at the end of a built dojo.js in a closure
+		require({ cache: {} });
+		!require.async && require(['dojo']);
+		require.boot && require.apply(null, require.boot);
+
+		require([ 'doh' ], function (doh) {
+			// begin test:
+			// moving modules from the pending cache to the module cache should ignore
+			// any mapping, pathing, or alias rules
+
+			doh.register('star-mapping', [
+				{
+					name: 'mapping after build',
+					runTest: function (t) {
+						var def = new doh.Deferred();
+
+						t.requireHandle = require.on('error', function (e) {
+							def.errback(e);
+						});
+						require(['my/A'], def.getTestCallback(function (A) {
+							t.is('is a replacement module', A.it, 'A should be a replacement module');
+						}));
+
+						return def;
+					},
+					tearDown: function (t) {
+						t.requireHandle.remove();
+					}
+				}
+			]);
+			doh.runOnLoad();
+		});
+	</script>
+</body>
+</html>

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