Permalink
Browse files

Fixes typo reported by NoKarma that caused module.exports assignments…

… to not work if the the 'module' dependency was not the last dependency in the list. Nice find. Added a new unit test so this does not regress in the future.
  • Loading branch information...
jrburke committed Oct 1, 2010
1 parent 415faea commit 079e8b1e0abd4b77f0cd898c4bd77f24581942f5
Showing with 8 additions and 3 deletions.
  1. +1 −1 require.js
  2. +4 −0 tests/exports/assign2.js
  3. +3 −2 tests/exports/exports-tests.js
View
@@ -1315,7 +1315,7 @@ var require;
ret = defined[name];
} else {
if (cjsModule && "exports" in cjsModule) {
- ret = defined[name] = depModule.exports;
+ ret = defined[name] = cjsModule.exports;
} else {
if (name in defined && !usingExports) {
req.onError(new Error(name + " has already been defined"));
View
@@ -0,0 +1,4 @@
+require.def(["module", "exports", "require"],
+ function (module, exports, require) {
+ module.exports = "assign2";
+});
@@ -1,15 +1,16 @@
require({
baseUrl: require.isBrowser ? "./" : "./exports/"
},
- ["require", "vanilla", "funcSet", "assign"],
- function(require, vanilla, funcSet, assign) {
+ ["require", "vanilla", "funcSet", "assign", "assign2"],
+ function(require, vanilla, funcSet, assign, assign2) {
doh.register(
"exports",
[
function exports(t){
t.is("vanilla", vanilla.name);
t.is("funcSet", funcSet);
t.is("assign", assign);
+ t.is("assign2", assign2);
}
]
);

0 comments on commit 079e8b1

Please sign in to comment.