runRoute function (dead code)
aplicacionamedida opened this issue · 0 comments
aplicacionamedida commented
I observed some dead code in the funciton runRoute():
if (typeof(route.callback) === "function") {
route.callback = [route.callback];
}
if (route.callback && route.callback.length) {
i = -1;
nextRoute = function() {
i++;
if (route.callback[i]) {
returned = route.callback[i].apply(context,callback_args);
} else if (app._onComplete && typeof(app._onComplete === "function")) {
app._onComplete(context);
}
};
callback_args.push(nextRoute);
nextRoute();
}
Variable "i" has no meaning, because a chain of callback is not well implemented.
For this reason, I think that this code should be deleted also:
if (typeof(route.callback) === "function") {
route.callback = [route.callback];
}
Callback should be always a function. Never an array.
For this reason this code , also has to be changed:
if (route.callback[i]) {