Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(debounce): fix argument slicing
Browse files Browse the repository at this point in the history
Closes #4859
Closes #4860
  • Loading branch information
Astashenkau authored and wesleycho committed Nov 10, 2015
1 parent a5bafe6 commit e196be8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/debounce/debounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ angular.module('ui.bootstrap.debounce', [])

return function() {
var self = this;
var args = Array.prototype.slice(arguments);
var args = Array.prototype.slice.call(arguments);
if (timeoutPromise) {
$timeout.cancel(timeoutPromise);
}
Expand All @@ -18,4 +18,4 @@ angular.module('ui.bootstrap.debounce', [])
}, debounceTime);
};
};
}]);
}]);
10 changes: 9 additions & 1 deletion src/debounce/test/debounce.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
describe('$$debounce', function() {
var $$debounce, $timeout, debouncedFunction, i;
var $$debounce, $timeout, debouncedFunction, i, args;

beforeEach(module('ui.bootstrap.debounce'));
beforeEach(inject(function(_$$debounce_, _$timeout_) {
$$debounce = _$$debounce_;
$timeout = _$timeout_;
i = 0;
debouncedFunction = $$debounce(function() {
args = Array.prototype.slice.call(arguments);
i++;
}, 100);
}));
Expand Down Expand Up @@ -37,4 +38,11 @@ describe('$$debounce', function() {

expect(i).toBe(1);
});

it('should properly pass arguments to debounced function', function() {
debouncedFunction(1, 2, 3);
$timeout.flush(100);

expect(args).toEqual([1, 2, 3]);
});
});

0 comments on commit e196be8

Please sign in to comment.