Skip to content

Commit

Permalink
Fix isEquals null check: check for constructor in the objects per @jd…
Browse files Browse the repository at this point in the history
  • Loading branch information
akre54 committed Nov 7, 2013
1 parent 4dcff63 commit b502137
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/objects.js
Expand Up @@ -366,6 +366,12 @@ $(document).ready(function() {
b = {x: 1};
ok(_.isEqual(a, b));
}

function Foo() { this.a = 1; }
Foo.prototype.constructor = null;

var other = { 'a': 1 };
strictEqual(_.isEqual(new Foo, other), false);
});

test("isEmpty", function() {
Expand Down
2 changes: 1 addition & 1 deletion underscore.js
Expand Up @@ -933,7 +933,7 @@
var aCtor = a.constructor, bCtor = b.constructor;
if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
_.isFunction(bCtor) && (bCtor instanceof bCtor))
&& !(aCtor == null || bCtor == null)) {
&& ('constructor' in a && 'constructor' in b)) {
return false;
}
// Add the first object to the stack of traversed objects.
Expand Down

0 comments on commit b502137

Please sign in to comment.