From 4c9282dc88f097020dd2b3b98b3d6cb246a27e88 Mon Sep 17 00:00:00 2001 From: jrburke Date: Tue, 15 Mar 2016 18:59:28 -0700 Subject: [PATCH] Revert "Fixes #1440, error in require callback preventing other resolution" This reverts commit d863f9c43bd58fc364aa3850b14d0f06255215fa. --- require.js | 45 ++++++++++++---------------- tests/all.js | 1 - tests/requireError/a.js | 5 ---- tests/requireError/b.js | 6 ---- tests/requireError/requireError.html | 34 --------------------- 5 files changed, 19 insertions(+), 72 deletions(-) delete mode 100644 tests/requireError/a.js delete mode 100644 tests/requireError/b.js delete mode 100644 tests/requireError/requireError.html diff --git a/require.js b/require.js index b4e11c25b..0e8be2cd6 100644 --- a/require.js +++ b/require.js @@ -864,10 +864,21 @@ var requirejs, require, define; if (this.depCount < 1 && !this.defined) { if (isFunction(factory)) { - try { + //If there is an error listener, favor passing + //to that instead of throwing an error. However, + //only do it for define()'d modules. require + //errbacks should not be called for failures in + //their callbacks (#699). However if a global + //onError is set, use that. + if ((this.events.error && this.map.isDefine) || + req.onError !== defaultOnError) { + try { + exports = context.execCb(id, factory, depExports, exports); + } catch (e) { + err = e; + } + } else { exports = context.execCb(id, factory, depExports, exports); - } catch (e) { - err = e; } // Favor return value over exports. If node/cjs in play, @@ -884,30 +895,12 @@ var requirejs, require, define; } if (err) { - // If there is an error listener, favor passing - // to that instead of throwing an error. However, - // only do it for define()'d modules. require - // errbacks should not be called for failures in - // their callbacks (#699). However if a global - // onError is set, use that. - if ((this.events.error && this.map.isDefine) || - req.onError !== defaultOnError) { - err.requireMap = this.map; - err.requireModules = this.map.isDefine ? [this.map.id] : null; - err.requireType = this.map.isDefine ? 'define' : 'require'; - return onError((this.error = err)); - } else if (typeof console !== 'undefined' && - console.error) { - // Log the error for debugging. If promises could be - // used, this would be different, but making do. - console.error(err); - } else { - // Do not want to completely lose the error. While this - // will mess up processing and lead to similar results - // as bug 1440, it at least surfaces the error. - req.onError(err); - } + err.requireMap = this.map; + err.requireModules = this.map.isDefine ? [this.map.id] : null; + err.requireType = this.map.isDefine ? 'define' : 'require'; + return onError((this.error = err)); } + } else { //Just a literal value exports = factory; diff --git a/tests/all.js b/tests/all.js index a8e04f4c2..18ee49c77 100644 --- a/tests/all.js +++ b/tests/all.js @@ -155,7 +155,6 @@ doh.registerUrl("pluginNormalize", "../plugins/pluginNormalize/pluginNormalize.h doh.registerUrl("requirePluginLoad", "../requirePluginLoad/requirePluginLoad.html"); doh.registerUrl("requireAsync", "../requireAsync/requireAsync.html"); -doh.registerUrl("requireError", "../requireError/requireError.html"); doh.registerUrl("issue379", "../issue379/issue379.html"); diff --git a/tests/requireError/a.js b/tests/requireError/a.js deleted file mode 100644 index 91d508c08..000000000 --- a/tests/requireError/a.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function() { - return { - name: 'a' - }; -}); \ No newline at end of file diff --git a/tests/requireError/b.js b/tests/requireError/b.js deleted file mode 100644 index 3ac9be40c..000000000 --- a/tests/requireError/b.js +++ /dev/null @@ -1,6 +0,0 @@ -define(['a'], function(a) { - return { - name: 'b', - a: a - }; -}); diff --git a/tests/requireError/requireError.html b/tests/requireError/requireError.html deleted file mode 100644 index 266969070..000000000 --- a/tests/requireError/requireError.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - require.js: require Error in Callback Test - - - - - - -

require.js: require Error in Callback Test

-

Error in require callback does not stop other resolution. - More info.

-

Check console for messages

- -