mergeWith: stack passed to customizer should always be defined (#4244)

Summary:
If the first values encountered in the `object` in mergeWith are not objects, `stack` is undefined when passed to the `customizer`. Once the first object-ish value is encountered, `stack` gets initialized, and all further calls to `customizer` include a defined `stack`. This PR makes `stack` always defined, even before the first object-ish value is encountered.
This commit is contained in:
Marc Hassan
2019-03-21 23:54:53 -04:00
committed by John-David Dalton
parent 7084300d34
commit 0b8592a35c
2 changed files with 12 additions and 9 deletions

View File

@@ -15280,18 +15280,21 @@
});
QUnit.test('should provide `stack` to `customizer`', function(assert) {
assert.expect(1);
assert.expect(4);
var actual;
var actual = [];
_.mergeWith({}, { 'a': { 'b': 2 } }, function() {
actual = _.last(arguments);
_.mergeWith({}, { 'z': 1, 'a': { 'b': 2 } }, function() {
actual.push(_.last(arguments));
});
assert.ok(isNpm
? actual.constructor.name == 'Stack'
: actual instanceof mapCaches.Stack
);
assert.strictEqual(actual.length, 3);
_.each(actual, function(a) {
assert.ok(isNpm
? a.constructor.name == 'Stack'
: a instanceof mapCaches.Stack
);
});
});
QUnit.test('should overwrite primitives with source object clones', function(assert) {