Skip to content

Commit

Permalink
fix bug where rejected legacy scripts leads to terminated script exec…
Browse files Browse the repository at this point in the history
…ution
  • Loading branch information
dlueth committed Oct 6, 2020
1 parent 0c4cbb1 commit 7aef0ac
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion dist/cache/dispose.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cache/states.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/demand.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/demand.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/handler/css.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/html.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/json.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/legacy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/text.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/cookie.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/lzstring.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/sri.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "qoopido.demand",
"title": "Qoopido.demand",
"description": "Promise like module loader using XHR requests and localStorage caching to dynamically load JavaScript and CSS + dynamic dependency resolution + support for custom handlers",
"version": "7.1.5",
"version": "7.1.6",
"homepage": "https://github.com/dlueth/qoopido.demand",
"author": {
"name": "Dirk Lueth",
Expand Down
7 changes: 4 additions & 3 deletions src/class/dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ var ClassDependency = (function() {
self.pledge = self.dfd.pledge;
self.invalid = false;

self.pledge.then(function() {
self.value = functionToArray(arguments);
});
self.pledge.then(
function() { self.value = functionToArray(arguments); },
function() { processor.current && processor.process(); }
);

(register !== FALSE) && registry.set(self.id, self);

Expand Down
16 changes: 11 additions & 5 deletions src/function/provide.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ provide = function provide() {
context = this !== global ? this : NULL,
dependencies = validatorIsArray(arguments[uri ? 1 : 0]) ? arguments[uri ? 1 : 0] : NULL,
definition = dependencies ? arguments[uri ? 2 : 1] : arguments[uri ? 1 : 0],
module, isThenable, isFunction;
module, isThenable, isFunction, value;

if(processor.current) {
module = processor.current;
Expand All @@ -40,8 +40,6 @@ provide = function provide() {
.apply(module.path, dependencies)
.then(
function() {
var value;

if(isFunction) {
try {
value = definition.apply(NULL, arguments);
Expand All @@ -57,7 +55,7 @@ provide = function provide() {
module.dfd.resolve(module.value || value);
}
} catch(error) {
module.dfd.reject(new ClassFailure(ERROR_PROVIDE, module.id, arguments));
module.dfd.reject(new ClassFailure(ERROR_PROVIDE, module.id, error));
}
} else {
module.dfd.resolve(definition);
Expand All @@ -69,7 +67,15 @@ provide = function provide() {
if(isThenable) {
definition.then(module.dfd.resolve, module.dfd.reject);
} else {
module.dfd.resolve(isFunction ? definition() : definition);
if(isFunction) {
try {
module.dfd.resolve(definition());
} catch (error) {
module.dfd.reject(new ClassFailure(ERROR_PROVIDE, module.id, error));
}
} else {
module.dfd.resolve(definition);
}
}
}

Expand Down

0 comments on commit 7aef0ac

Please sign in to comment.