Ensure _.bind correctly appends array arguments to partially applied arguments.

Former-commit-id: 4fdb100f83ff9a0eafcba3f5bf91872748205595
This commit is contained in:
John-David Dalton
2012-08-18 00:48:14 -07:00
parent 15b14e12e2
commit 04425786a1
2 changed files with 9 additions and 1 deletions

View File

@@ -3224,7 +3224,7 @@
} }
if (partialArgs.length) { if (partialArgs.length) {
args = args.length args = args.length
? concat.apply(partialArgs, args) ? partialArgs.concat(slice.call(args))
: partialArgs; : partialArgs;
} }
if (this instanceof bound) { if (this instanceof bound) {

View File

@@ -143,6 +143,14 @@
QUnit.module('lodash.bind'); QUnit.module('lodash.bind');
(function() { (function() {
test('should correctly append array arguments to partially applied arguments (test in IE < 9)', function() {
var args,
bound = _.bind(function() { args = slice.call(arguments); }, null, 'a');
bound(['b'], 'c');
deepEqual(args, ['a', ['b'], 'c']);
});
test('supports lazy bind', function() { test('supports lazy bind', function() {
var object = { var object = {
'name': 'moe', 'name': 'moe',