diff --git a/reflections/shape/shape-test.js b/reflections/shape/shape-test.js index 02be6ce..7ead2ca 100644 --- a/reflections/shape/shape-test.js +++ b/reflections/shape/shape-test.js @@ -184,8 +184,6 @@ QUnit.test("toArray", function(){ QUnit.module('can-reflect: shape reflections: own'); QUnit.test("hasOwnKey", function(){ - - var map; // Defined on something @@ -204,6 +202,16 @@ QUnit.test("hasOwnKey", function(){ }); +QUnit.test("hasOwnKey on null derived object", function(){ + var obj = Object.create(null); + obj.foo = "bar"; + + QUnit.ok( shapeReflections.hasOwnKey(obj, "foo") , "obj" ); + QUnit.ok( !shapeReflections.hasOwnKey(obj, "bar") , "obj" ); + +}); + + QUnit.test("getOwnKeys", function(){ var obj = Object.create(null,{ foo: {value: "1", enumerable: true}, diff --git a/reflections/shape/shape.js b/reflections/shape/shape.js index a7a0051..17235fc 100644 --- a/reflections/shape/shape.js +++ b/reflections/shape/shape.js @@ -73,6 +73,8 @@ if(typeof Map === "function") { // IE-remove-end } +var hasOwnProperty = Object.prototype.hasOwnProperty; + var shapeReflections; var shiftFirstArgumentToThis = function(func){ @@ -556,7 +558,7 @@ shapeReflections = { }); return found; } - return obj.hasOwnProperty(key); + return hasOwnProperty.call(obj, key); }, /** * @function can-reflect.getOwnEnumerableKeys getOwnEnumerableKeys @@ -1057,7 +1059,7 @@ shapeReflections = { return false; } if (typeReflections.isPrimitive(obj)) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { + if (hasOwnProperty.call(obj, key)) { return true; } else { var proto;