diff --git a/lib/backburner.js b/lib/backburner.js index 64668f9e..59ee566d 100644 --- a/lib/backburner.js +++ b/lib/backburner.js @@ -119,18 +119,34 @@ Backburner.prototype = { } }, - join: function(target, method /*, args */) { + join: function(/* target, method , args */) { + var method, target; + if (this.currentInstance) { - if (!method) { - method = target; + var length = arguments.length; + if (length === 1) { + method = arguments[0]; target = null; + } else { + target = arguments[0]; + method = arguments[1]; } if (isString(method)) { method = target[method]; } - return method.apply(target, slice.call(arguments, 2)); + if (length === 1) { + return method(); + } else if (length === 2) { + return method.call(target); + } else { + var args = new Array(length - 2); + for (var i =0, l = length - 2; i < l; i++) { + args[i] = arguments[i + 2]; + } + return method.apply(target, args); + } } else { return this.run.apply(this, arguments); }