From f90c3f24837c3288f720dfd4591a81a1ad60f976 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 19 May 2016 19:47:20 -0700 Subject: [PATCH] Ensure `_.pullAll` works with the same value for `array` and `values`. [closes #2356] --- lodash.js | 3 +++ test/test.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lodash.js b/lodash.js index ac687729d..c6006e01f 100644 --- a/lodash.js +++ b/lodash.js @@ -3394,6 +3394,9 @@ length = values.length, seen = array; + if (array === values) { + values = copyArray(values); + } if (iteratee) { seen = arrayMap(array, baseUnary(iteratee)); } diff --git a/test/test.js b/test/test.js index 736e0decd..ae1921c44 100644 --- a/test/test.js +++ b/test/test.js @@ -18081,6 +18081,21 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.pullAll'); + + (function() { + QUnit.test('should work with the same value for `array` and `values`', function(assert) { + assert.expect(1); + + var array = [{ 'a': 1 }, { 'b': 2 }], + actual = _.pullAll(array, array); + + assert.deepEqual(actual, []); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.pullAllBy'); (function() {