Allow null prototype obj to be compared for equals

Fixes #729
This commit is contained in:
Rohit Arondekar
2014-12-20 08:35:27 +05:30
parent 9f240c5b9e
commit a84eaf2cbe
2 changed files with 21 additions and 1 deletions

View File

@@ -250,6 +250,26 @@ describe("matchersUtil", function() {
expect(j$.matchersUtil.equals(any1, any2)).toBe(true);
});
it("passes for null prototype objects with same properties", function () {
var objA = Object.create(null),
objB = Object.create(null);
objA.name = 'test';
objB.name = 'test';
expect(j$.matchersUtil.equals(objA, objB)).toBe(true);
});
it("fails for null prototype objects with different properties", function () {
var objA = Object.create(null),
objB = Object.create(null);
objA.name = 'test';
objB.test = 'name';
expect(j$.matchersUtil.equals(objA, objB)).toBe(false);
});
});
describe("contains", function() {

View File

@@ -197,7 +197,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
return result;
function has(obj, key) {
return obj.hasOwnProperty(key);
return Object.prototype.hasOwnProperty.call(obj, key);
}
function isFunction(obj) {