mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Ensure trailing function sources aren't skipping for _.assign, _.assignIn, _.defaults, & _.merge. [closes #2311]
This commit is contained in:
@@ -4322,7 +4322,7 @@
|
|||||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||||
guard = length > 2 ? sources[2] : undefined;
|
guard = length > 2 ? sources[2] : undefined;
|
||||||
|
|
||||||
customizer = typeof customizer == 'function'
|
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
||||||
? (length--, customizer)
|
? (length--, customizer)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
16
test/test.js
16
test/test.js
@@ -6813,6 +6813,15 @@
|
|||||||
assert.deepEqual(func({}, new Foo), expected);
|
assert.deepEqual(func({}, new Foo), expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` should not skip a trailing function source', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
function fn() {}
|
||||||
|
fn.b = 2;
|
||||||
|
|
||||||
|
assert.deepEqual(func({}, { 'a': 1 }, fn), { 'a': 1, 'b': 2 });
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should not error on nullish sources', function(assert) {
|
QUnit.test('`_.' + methodName + '` should not error on nullish sources', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
@@ -6850,14 +6859,13 @@
|
|||||||
var array = [{ 'a': 1 }, { 'b': 2 }, { 'c': 3 }],
|
var array = [{ 'a': 1 }, { 'b': 2 }, { 'c': 3 }],
|
||||||
expected = { 'a': isDefaults ? 0 : 1, 'b': 2, 'c': 3 };
|
expected = { 'a': isDefaults ? 0 : 1, 'b': 2, 'c': 3 };
|
||||||
|
|
||||||
assert.deepEqual(lodashStable.reduce(array, func, { 'a': 0 }), expected);
|
function fn() {};
|
||||||
|
|
||||||
var fn = function() {};
|
|
||||||
fn.a = array[0];
|
fn.a = array[0];
|
||||||
fn.b = array[1];
|
fn.b = array[1];
|
||||||
fn.c = array[2];
|
fn.c = array[2];
|
||||||
|
|
||||||
assert.deepEqual(_.reduce(fn, func, { 'a': 0 }), expected);
|
assert.deepEqual(lodashStable.reduce(array, func, { 'a': 0 }), expected);
|
||||||
|
assert.deepEqual(lodashStable.reduce(fn, func, { 'a': 0 }), expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should not return the existing wrapped value when chaining', function(assert) {
|
QUnit.test('`_.' + methodName + '` should not return the existing wrapped value when chaining', function(assert) {
|
||||||
|
|||||||
Reference in New Issue
Block a user