diff --git a/lodash.js b/lodash.js index 926a8a840..baafa2154 100644 --- a/lodash.js +++ b/lodash.js @@ -3304,16 +3304,16 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { var objIsArr = isArray(object), othIsArr = isArray(other), - objTag = arrayTag, - othTag = arrayTag; + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); - if (!objIsArr) { - objTag = getTag(object); - objTag = objTag == argsTag ? objectTag : objTag; + if (objTag == argsTag) { + objTag = objectTag; + object = copyObject(object, keys(object)); } - if (!othIsArr) { - othTag = getTag(other); - othTag = othTag == argsTag ? objectTag : othTag; + if (othTag == argsTag) { + othTag = objectTag; + other = copyObject(other, keys(other)); } var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, @@ -5816,9 +5816,9 @@ */ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - objProps = keys(object), + objProps = getAllKeys(object), objLength = objProps.length, - othProps = keys(other), + othProps = getAllKeys(other), othLength = othProps.length; if (objLength != othLength && !isPartial) { diff --git a/test/test.js b/test/test.js index fac2701e7..b2431d0ab 100644 --- a/test/test.js +++ b/test/test.js @@ -9815,7 +9815,7 @@ assert.strictEqual(_.isEqual(object1, object2), true); }); - QUnit.test('should treat objects created by `Object.create(null)` like a plain object', function(assert) { + QUnit.test('should treat objects created by `Object.create(null)` like plain objects', function(assert) { assert.expect(2); function Foo() { @@ -9832,22 +9832,6 @@ assert.strictEqual(_.isEqual(new Foo, object2), false); }); - QUnit.test('should return `false` for objects with custom `toString` methods', function(assert) { - assert.expect(1); - - var primitive, - object = { 'toString': function() { return primitive; } }, - values = [true, null, 1, 'a', undefined], - expected = lodashStable.map(values, stubFalse); - - var actual = lodashStable.map(values, function(value) { - primitive = value; - return _.isEqual(object, value); - }); - - assert.deepEqual(actual, expected); - }); - QUnit.test('should avoid common type coercions', function(assert) { assert.expect(9); @@ -10123,42 +10107,25 @@ } }); - QUnit.test('should work as an iteratee for `_.every`', function(assert) { - assert.expect(1); + QUnit.test('should compare symbol properties', function(assert) { + assert.expect(3); - var actual = lodashStable.every([1, 1, 1], lodashStable.partial(_.isEqual, 1)); - assert.ok(actual); - }); + if (Symbol) { + var object1 = { 'a': 1 }, + object2 = { 'a': 1 }; - QUnit.test('should return `true` for like-objects from different documents', function(assert) { - assert.expect(4); + object1[symbol] = object2[symbol] = 2; + assert.strictEqual(_.isEqual(object1, object2), true); - if (realm.object) { - assert.strictEqual(_.isEqual([1], realm.array), true); - assert.strictEqual(_.isEqual([2], realm.array), false); - assert.strictEqual(_.isEqual({ 'a': 1 }, realm.object), true); - assert.strictEqual(_.isEqual({ 'a': 2 }, realm.object), false); + object2[symbol] = 3; + assert.strictEqual(_.isEqual(object1, object2), false); + + delete object2[symbol]; + object2[Symbol('a')] = 2; + assert.strictEqual(_.isEqual(object1, object2), false); } else { - skipAssert(assert, 4); - } - }); - - QUnit.test('should not error on DOM elements', function(assert) { - assert.expect(1); - - if (document) { - var element1 = document.createElement('div'), - element2 = element1.cloneNode(true); - - try { - assert.strictEqual(_.isEqual(element1, element2), false); - } catch (e) { - assert.ok(false, e.message); - } - } - else { - skipAssert(assert); + skipAssert(assert, 3); } }); @@ -10221,6 +10188,61 @@ } }); + QUnit.test('should work as an iteratee for `_.every`', function(assert) { + assert.expect(1); + + var actual = lodashStable.every([1, 1, 1], lodashStable.partial(_.isEqual, 1)); + assert.ok(actual); + }); + + QUnit.test('should not error on DOM elements', function(assert) { + assert.expect(1); + + if (document) { + var element1 = document.createElement('div'), + element2 = element1.cloneNode(true); + + try { + assert.strictEqual(_.isEqual(element1, element2), false); + } catch (e) { + assert.ok(false, e.message); + } + } + else { + skipAssert(assert); + } + }); + + QUnit.test('should return `true` for like-objects from different documents', function(assert) { + assert.expect(4); + + if (realm.object) { + assert.strictEqual(_.isEqual([1], realm.array), true); + assert.strictEqual(_.isEqual([2], realm.array), false); + assert.strictEqual(_.isEqual({ 'a': 1 }, realm.object), true); + assert.strictEqual(_.isEqual({ 'a': 2 }, realm.object), false); + } + else { + skipAssert(assert, 4); + } + }); + + QUnit.test('should return `false` for objects with custom `toString` methods', function(assert) { + assert.expect(1); + + var primitive, + object = { 'toString': function() { return primitive; } }, + values = [true, null, 1, 'a', undefined], + expected = lodashStable.map(values, stubFalse); + + var actual = lodashStable.map(values, function(value) { + primitive = value; + return _.isEqual(object, value); + }); + + assert.deepEqual(actual, expected); + }); + QUnit.test('should return an unwrapped value when implicitly chaining', function(assert) { assert.expect(1);