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

Commit e196be8

Browse files
Astashenkauwesleycho
Astashenkau
authored andcommitted
fix(debounce): fix argument slicing
Closes #4859 Closes #4860
1 parent a5bafe6 commit e196be8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/debounce/debounce.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ angular.module('ui.bootstrap.debounce', [])
88

99
return function() {
1010
var self = this;
11-
var args = Array.prototype.slice(arguments);
11+
var args = Array.prototype.slice.call(arguments);
1212
if (timeoutPromise) {
1313
$timeout.cancel(timeoutPromise);
1414
}
@@ -18,4 +18,4 @@ angular.module('ui.bootstrap.debounce', [])
1818
}, debounceTime);
1919
};
2020
};
21-
}]);
21+
}]);

src/debounce/test/debounce.spec.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
describe('$$debounce', function() {
2-
var $$debounce, $timeout, debouncedFunction, i;
2+
var $$debounce, $timeout, debouncedFunction, i, args;
33

44
beforeEach(module('ui.bootstrap.debounce'));
55
beforeEach(inject(function(_$$debounce_, _$timeout_) {
66
$$debounce = _$$debounce_;
77
$timeout = _$timeout_;
88
i = 0;
99
debouncedFunction = $$debounce(function() {
10+
args = Array.prototype.slice.call(arguments);
1011
i++;
1112
}, 100);
1213
}));
@@ -37,4 +38,11 @@ describe('$$debounce', function() {
3738

3839
expect(i).toBe(1);
3940
});
41+
42+
it('should properly pass arguments to debounced function', function() {
43+
debouncedFunction(1, 2, 3);
44+
$timeout.flush(100);
45+
46+
expect(args).toEqual([1, 2, 3]);
47+
});
4048
});

0 commit comments

Comments
 (0)