Skip to content

Commit

Permalink
fix: work around $.when() resolving with arguments.length = 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Sep 6, 2016
1 parent b066381 commit 2ba2d73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion jquery.wire.js
Expand Up @@ -8,11 +8,14 @@
}
})(this, function($) {
var slice = Array.prototype.slice;
var resolved = $.Deferred(function (dfd) {
dfd.resolve();
});

return function(input, callback) {
var args = slice.call(arguments, 2);

return $.when.apply(null, this.map(function(i, element) {
return this.length === 0 ? resolved : $.when.apply(null, this.map(function(i, element) {
return $.when.apply(null, input
.apply(element, args)
.map(function(output, index) {
Expand Down

0 comments on commit 2ba2d73

Please sign in to comment.