diff --git a/lodash.js b/lodash.js index a19f9c408..91ae02efa 100644 --- a/lodash.js +++ b/lodash.js @@ -2476,10 +2476,9 @@ * @param {boolean} [isDeep] Specify a deep flatten. * @param {boolean} [isStrict] Restrict flattening to arrays-like objects. * @param {Array} [result=[]] The initial result value. - * @param {Object} [stack] Tracks traversed arrays. * @returns {Array} Returns the new flattened array. */ - function baseFlatten(array, isDeep, isStrict, result, stack) { + function baseFlatten(array, isDeep, isStrict, result) { result || (result = []); var index = -1, @@ -2490,18 +2489,9 @@ if (isArrayLikeObject(value) && (isStrict || isArray(value) || isArguments(value))) { if (isDeep) { - stack || (stack = new Stack); - if (stack.get(array)) { - return result; - } - stack.set(array, true); - // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, isDeep, isStrict, result, stack); - - stack['delete'](array); - } - else { + baseFlatten(value, isDeep, isStrict, result); + } else { arrayPush(result, value); } } else if (!isStrict) { diff --git a/test/test.js b/test/test.js index 84d04c379..bd166d750 100644 --- a/test/test.js +++ b/test/test.js @@ -5276,32 +5276,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.flattenDeep'); - - (function() { - QUnit.test('should flatten arrays with circular references', function(assert) { - assert.expect(2); - - var array = [1, 2]; - array.push(array); - - var expected = [1, 2, 1, 2]; - - try { - var actual = _.flattenDeep(array); - } catch (e) {} - - assert.deepEqual(actual, expected); - - array = [1, 2]; - array = [array, [array]]; - - assert.deepEqual(_.flattenDeep(array), expected); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('flatten methods'); (function() {