Skip to content

Commit 26404fe

Browse files
committed
Fixes requirejs#1131, nested plugin use mangled in normalization
1 parent 5799492 commit 26404fe

File tree

6 files changed

+56
-1
lines changed

6 files changed

+56
-1
lines changed

require.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,16 @@ var requirejs, require, define;
444444
return normalize(name, parentName, applyMap);
445445
});
446446
} else {
447-
normalizedName = normalize(name, parentName, applyMap);
447+
// If nested plugin references, then do not try to
448+
// normalize, as it will not normalize correctly. This
449+
// places a restriction on resourceIds, and the longer
450+
// term solution is not to normalize until plugins are
451+
// loaded and all normalizations to allow for async
452+
// loading of a loader plugin. But for now, fixes the
453+
// common uses. Details in #1131
454+
normalizedName = name.indexOf('!') === -1 ?
455+
normalize(name, parentName, applyMap) :
456+
name;
448457
}
449458
} else {
450459
//A regular module.

tests/all.js

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ doh.registerUrl("pluginMap", "../plugins/pluginMap/pluginMap.html");
138138
doh.registerUrl("pluginMapSameName", "../plugins/pluginMapSameName/pluginMapSameName.html");
139139
doh.registerUrl("pluginMapDynamic", "../plugins/pluginMap/dynamic/pluginMapDynamic.html");
140140
doh.registerUrl("pluginComplexNormalize", "../plugins/complexNormalize/complexNormalize.html");
141+
doh.registerUrl("pluginNormalize", "../plugins/pluginNormalize/pluginNormalize.html");
141142

142143
doh.registerUrl("requirePluginLoad", "../requirePluginLoad/requirePluginLoad.html");
143144

tests/plugins/pluginNormalize/modA.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
define(function() {
2+
return {
3+
load: function(name, req, onload, config) {
4+
req([name + '-foo'], onload, onload.error);
5+
}
6+
}
7+
});

tests/plugins/pluginNormalize/modB.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
define(function() {
2+
return {
3+
load: function(name, req, onload, config) {
4+
onload(name);
5+
}
6+
}
7+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require(['modA!modB!no-dotdot',
2+
'modA!modB!../one-dotdot',
3+
'modA!modB!../../two-dotdot-is-broken'], function (a, b, c) {
4+
5+
doh.register(
6+
"pluginNormalize",
7+
[
8+
function pluginNormalize(t){
9+
t.is('no-dotdot-foo', a);
10+
t.is('../one-dotdot-foo', b);
11+
t.is('../../two-dotdot-is-broken-foo', c);
12+
}
13+
]
14+
);
15+
16+
doh.run();
17+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>require.js: Nested Plugin Normalize Test</title>
5+
<script type="text/javascript" src="../../doh/runner.js"></script>
6+
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
7+
<script type="text/javascript" data-main="pluginNormalize-tests" src="../../../require.js"></script>
8+
</head>
9+
<body>
10+
<h1>require.js: Nested Plugin Normalize Test</h1>
11+
<p><a href="https://github.com/jrburke/requirejs/issues/1131">More info</a></p>
12+
<p>Check console for messages</p>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)