From 0fcf43b02b370ac6579c9d6aa1dc88e54f0b96c7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 31 Oct 2016 09:56:55 -0700 Subject: [PATCH] Ensure `_.xor` returns an empty array when comparing the same array. [closes #2776] --- lodash.js | 2 +- test/test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index feabafd3b..367ad55cc 100644 --- a/lodash.js +++ b/lodash.js @@ -4414,7 +4414,7 @@ while (++othIndex < length) { var othArray = arrays[othIndex]; - if (othArray !== array) { + if (othIndex != index) { result[index] = baseDifference(result[index] || array, othArray, iteratee, comparator); } } diff --git a/test/test.js b/test/test.js index e4d2ea5f6..1a70402d5 100644 --- a/test/test.js +++ b/test/test.js @@ -25279,6 +25279,15 @@ assert.deepEqual(actual, []); }); + QUnit.test('`_.' + methodName + '` should return an empty array when comparing the same array', function(assert) { + assert.expect(1); + + var array = [1], + actual = func(array, array, array); + + assert.deepEqual(actual, []); + }); + QUnit.test('`_.' + methodName + '` should return an array of unique values', function(assert) { assert.expect(2);