From efd3726c6dec4f5b8cb197cffebe06f68ad466d8 Mon Sep 17 00:00:00 2001 From: John Hann Date: Tue, 28 Feb 2012 18:28:31 -0500 Subject: [PATCH] no longer tests for modules in the cache by checking for truthiness (leftover from earlier assumption that all modules would have exports objects). with tests --- src/curl.js | 9 +-- test/module-returns-undefined.html | 104 +++++++++++++++++++++++++++++ test/stuff/undefined-module.js | 3 + 3 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 test/module-returns-undefined.html create mode 100644 test/stuff/undefined-module.js diff --git a/src/curl.js b/src/curl.js index b903f6ee..e490e285 100644 --- a/src/curl.js +++ b/src/curl.js @@ -820,9 +820,10 @@ } } - // find resource definition + // find resource definition. ALWAYS check via (id in cache) b/c + // falsey values could be in there. def = cache[mainId]; - if (!def) { + if (!(mainId in cache)) { def = cache[mainId] = core.createResourceDef(pathInfo.config, mainId, isPreload, !!parts.pluginId ? pathInfo.path : undef); def.url = core.checkToAddJsExt(pathInfo.url); core.fetchResDef(def); @@ -865,7 +866,7 @@ normalizedDef = cache[fullId]; // if this is our first time fetching this (normalized) def - if (!normalizedDef) { + if (!(fullId in cache)) { // because we're using resId, plugins, such as wire!, // can use paths relative to the resource @@ -983,7 +984,7 @@ // named define(), it is in the cache if we are loading a dependency // (could also be a secondary define() appearing in a built file, etc.) var def = cache[id]; - if (!def) { + if (!(id in cache)) { // id is an absolute id in this case, so we can get the config. // there's no way to allow a named define to fetch dependencies // in the preload phase since we can't cascade the parent def. diff --git a/test/module-returns-undefined.html b/test/module-returns-undefined.html new file mode 100644 index 00000000..e3c9bc72 --- /dev/null +++ b/test/module-returns-undefined.html @@ -0,0 +1,104 @@ + + + +undefined module loads once + + + + + + + + + + + + + diff --git a/test/stuff/undefined-module.js b/test/stuff/undefined-module.js new file mode 100644 index 00000000..98f3d3ff --- /dev/null +++ b/test/stuff/undefined-module.js @@ -0,0 +1,3 @@ +define(function () { + // returns nothing +}); \ No newline at end of file