Ensure _.isEqual works with objects created by Object.create(null).

This commit is contained in:
John-David Dalton
2013-10-17 22:53:40 -07:00
parent 0b4fe85b33
commit 31e86a36f8
8 changed files with 124 additions and 94 deletions

View File

@@ -429,7 +429,7 @@
this.a = function() { return this._a; };
};
Foo.prototype.b = function() {return this._b; };
Foo.prototype.b = function() { return this._b; };
var object = new Foo;
_.bindAll(object);
@@ -2744,7 +2744,24 @@
actual = _.every([array, [1, 0, 3]], eq);
strictEqual(actual, false);
})
});
test('should treat objects created by `Object.create(null)` like any other plain object', 2, function() {
function Foo() { this.a = 1; }
Foo.prototype.constructor = null;
var other = { 'a': 1 };
strictEqual(_.isEqual(new Foo, other), false);
if (create) {
var object = Object.create(null);
object.a = 1;
strictEqual(_.isEqual(object, other), true);
}
else {
skipTest();
}
});
}());
/*--------------------------------------------------------------------------*/