Skip to content

Commit

Permalink
Revert "Fixes #1440, error in require callback preventing other resol…
Browse files Browse the repository at this point in the history
…ution"

This reverts commit d863f9c.
  • Loading branch information
jrburke committed Mar 16, 2016
1 parent c5f7735 commit 4c9282d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 72 deletions.
45 changes: 19 additions & 26 deletions require.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion tests/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
5 changes: 0 additions & 5 deletions tests/requireError/a.js

This file was deleted.

6 changes: 0 additions & 6 deletions tests/requireError/b.js

This file was deleted.

34 changes: 0 additions & 34 deletions tests/requireError/requireError.html

This file was deleted.

0 comments on commit 4c9282d

Please sign in to comment.