8000 Ensure `_.xor` returns an empty array when comparing the same array. … · lodash/lodash@0fcf43b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fcf43b

Browse files
committed
Ensure _.xor returns an empty array when comparing the same array. [closes #2776]
1 parent 46d1f53 commit 0fcf43b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lodash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4414,7 +4414,7 @@
44144414

44154415
while (++othIndex < length) {
44164416
var othArray = arrays[othIndex];
4417-
if (othArray !== array) {
4417+
if (othIndex != index) {
44184418
result[index] = baseDifference(result[index] || array, othArray, iteratee, comparator);
44194419
}
44204420
}

test/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25279,6 +25279,15 @@
2527925279
assert.deepEqual(actual, []);
2528025280
});
2528125281

25282+
QUnit.test('`_.' + methodName + '` should return an empty array when comparing the same array', function(assert) {
25283+
assert.expect(1);
25284+
25285+
var array = [1],
25286+
actual = func(array, array, array);
25287+
25288+
assert.deepEqual(actual, []);
25289+
});
25290+
2528225291
QUnit.test('`_.' + methodName + '` should return an array of unique values', function(assert) {
2528325292
assert.expect(2);
2528425293

0 commit comments

Comments
 (0)
0