diff --git a/test/objects.js b/test/objects.js index b47de7fc4..f0a60ecfe 100644 --- a/test/objects.js +++ b/test/objects.js @@ -45,13 +45,15 @@ $(document).ready(function() { ok(_.isEqual(moe, clone), 'deep equality is true'); ok(_(moe).isEqual(clone), 'OO-style deep equality works'); ok(!_.isEqual(5, NaN), '5 is not equal to NaN'); - ok(NaN != NaN, 'NaN is not equal to NaN (native equality)'); - ok(NaN !== NaN, 'NaN is not equal to NaN (native identity)'); + ok(NaN != NaN, 'NaN is not equal to NaN (native equality)'); + ok(NaN !== NaN, 'NaN is not equal to NaN (native identity)'); ok(!_.isEqual(NaN, NaN), 'NaN is not equal to NaN'); ok(_.isEqual(new Date(100), new Date(100)), 'identical dates are equal'); ok(_.isEqual((/hello/ig), (/hello/ig)), 'identical regexes are equal'); ok(!_.isEqual(null, [1]), 'a falsy is never equal to a truthy'); - ok(!_.isEqual({x: 1, y: undefined}, {x: 1, z: 2}), 'object with the same number of undefined keys are not equal'); + ok(!_.isEqual({x: 1, y: undefined}, {x: 1, z: 2}), 'objects with the same number of undefined keys are not equal'); + ok(!_.isEqual(_({x: 1, y: undefined}).chain(), _({x: 1, z: 2}).chain()), 'wrapped objects are not equal'); + equals(_({x: 1, y: 2}).chain().isEqual(_({x: 1, y: 2}).chain()).value(), true, 'wrapped objects are equal'); }); test("objects: isEmpty", function() { diff --git a/underscore.js b/underscore.js index 887d039c3..ca580fc2b 100644 --- a/underscore.js +++ b/underscore.js @@ -519,6 +519,9 @@ // Perform a deep comparison to check if two objects are equal. _.isEqual = function(a, b) { + // Unwrap any wrapped objects + if (a && a._chain) a = a.value(); + if (b && b._chain) b = b.value(); // Check object identity. if (a === b) return true; // Different types?