From fcf18fb9657972f1649c81fec76abc3331485c24 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 10 Feb 2015 22:05:24 -0800 Subject: [PATCH] Remove `thisArg` from `_.spread`. [closes #957] --- lodash.src.js | 9 ++++----- test/test.js | 11 ++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 1bcb88eff..91ec72e8a 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -7643,15 +7643,14 @@ } /** - * Creates a function that invokes `func` with the `this` binding of `thisArg` - * and the array of arguments provided to the created function much like - * [Function#apply](http://es5.github.io/#x15.3.4.3). + * Creates a function that invokes `func` with the `this` binding of the + * created function and the array of arguments provided to the created + * function much like [Function#apply](http://es5.github.io/#x15.3.4.3). * * @static * @memberOf _ * @category Function * @param {Function} The function to spread arguments over. - * @param {*} [thisArg] The `this` binding of `func`. * @returns {*} Returns the new function. * @example * @@ -7680,7 +7679,7 @@ throw new TypeError(FUNC_ERROR_TEXT); } return function(array) { - return func.apply(thisArg, array); + return func.apply(this, array); }; } diff --git a/test/test.js b/test/test.js index dddda5b2d..f5e158f3f 100644 --- a/test/test.js +++ b/test/test.js @@ -12446,10 +12446,6 @@ QUnit.module('lodash.spread'); (function() { - function add(x, y) { - return x + y; - } - test('should spread arguments to `func`', 1, function() { var spread = _.spread(add); strictEqual(spread([4, 2]), 6); @@ -12470,12 +12466,13 @@ deepEqual(args, [4, 2]); }); - test('should support the `thisArg` argument', 1, function() { + test('should not set a `this` binding', 1, function() { var spread = _.spread(function(x, y) { return this[x] + this[y]; - }, [4, 2]); + }); - strictEqual(spread([0, 1]), 6); + var object = { 'spread': spread, 'x': 4, 'y': 2 }; + strictEqual(object.spread(['x', 'y']), 6); }); }());