From 0b76654b712b7bd5f2f15f782e8fa887d78346d3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 26 Feb 2016 09:33:30 -0800 Subject: [PATCH] Ensure `stack` is popped after recursive merge so that it doesn't affect sibling properties. [closes #2060] --- lodash.js | 1 + test/test.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 67227155c..3496f8a1f 100644 --- a/lodash.js +++ b/lodash.js @@ -3209,6 +3209,7 @@ // Recursively merge objects and arrays (susceptible to call stack limits). mergeFunc(newValue, srcValue, srcIndex, customizer, stack); } + stack['delete'](srcValue); assignMergeValue(object, key, newValue); } diff --git a/test/test.js b/test/test.js index 6343a80f5..869ce0e8c 100644 --- a/test/test.js +++ b/test/test.js @@ -14023,7 +14023,7 @@ source.bar.b = source.foo.b; var actual = _.merge(object, source); - assert.ok(actual.bar.b === actual.foo.b && actual.foo.b.c.d === actual.foo.b.c.d.foo.b.c.d); + assert.ok(actual.bar.b !== actual.foo.b && actual.foo.b.c.d === actual.foo.b.c.d.foo.b.c.d); }); QUnit.test('should work with four arguments', function(assert) {