Skip to content

Commit

Permalink
Merge pull request flatiron#213 from frekw/master
Browse files Browse the repository at this point in the history
Fix IE8 variable hoisting of apply function in  if/else.
  • Loading branch information
jcrugzz committed Dec 27, 2013
2 parents 2bb5571 + efc6b75 commit 414ad83
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/director/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,17 @@ Router.prototype.runlist = function (fns) {
Router.prototype.invoke = function (fns, thisArg, callback) {
var self = this;

var apply;
if (this.async) {
_asyncEverySeries(fns, function apply(fn, next) {
apply = function(fn, next){
if (Array.isArray(fn)) {
return _asyncEverySeries(fn, apply, next);
}
else if (typeof fn == 'function') {
fn.apply(thisArg, fns.captures.concat(next));
}
}, function () {
};
_asyncEverySeries(fns, apply, function () {
//
// Ignore the response here. Let the routed take care
// of themselves and eagerly return true.
Expand All @@ -434,7 +436,7 @@ Router.prototype.invoke = function (fns, thisArg, callback) {
});
}
else {
_every(fns, function apply(fn) {
apply = function(fn){
if (Array.isArray(fn)) {
return _every(fn, apply);
}
Expand All @@ -444,7 +446,8 @@ Router.prototype.invoke = function (fns, thisArg, callback) {
else if (typeof fn === 'string' && self.resource) {
self.resource[fn].apply(thisArg, fns.captures || []);
}
});
}
_every(fns, apply);
}
};

Expand Down

0 comments on commit 414ad83

Please sign in to comment.