From a8d368906128c6509dd4ac7362221a81c4a31bbf Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 2 Jul 2016 10:19:15 -0700 Subject: [PATCH] Ensure `_.isEqual` works more consistently with circular references. --- lodash.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lodash.js b/lodash.js index df54e5df5..802ee06dd 100644 --- a/lodash.js +++ b/lodash.js @@ -5230,7 +5230,7 @@ } // Assume cyclic values are equal. var stacked = stack.get(array); - if (stacked) { + if (stacked && stack.get(other)) { return stacked == other; } var index = -1, @@ -5238,6 +5238,7 @@ seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined; stack.set(array, other); + stack.set(other, array); // Ignore non-index properties. while (++index < arrLength) { @@ -5395,11 +5396,12 @@ } // Assume cyclic values are equal. var stacked = stack.get(object); - if (stacked) { + if (stacked && stack.get(other)) { return stacked == other; } var result = true; stack.set(object, other); + stack.set(other, object); var skipCtor = isPartial; while (++index < objLength) {