Skip to content

Commit

Permalink
Merge pull request #26 from normanzb/fix/get-prototype-of-return-null
Browse files Browse the repository at this point in the history
Object.getPrototypeOf should return null when the parameter is Object.prototype
  • Loading branch information
unscriptable committed Jul 25, 2013
2 parents 5994097 + 4dd4d88 commit 18e726a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions object.js
Expand Up @@ -87,6 +87,11 @@ define(['./lib/_base'], function (base) {
? function (object) { assertIsObject(object); return object.__proto__; }
: function (object) {
assertIsObject(object);
// return null according to the investigation result at:
// https://github.com/cujojs/poly/pull/21
if (object == refProto) {
return null;
}
return protoSecretProp && object[protoSecretProp](secrets)
? object[protoSecretProp](secrets.proto)
: object.constructor ? object.constructor.prototype : refProto;
Expand Down
6 changes: 6 additions & 0 deletions test/object.html
Expand Up @@ -183,6 +183,12 @@
return Object.getPrototypeOf(child) == proto;
});

// According to the investigation result at:
// https://github.com/cujojs/poly/pull/21/files
tester.assertTrue('Object.getPrototypeOf should return null when the parameter is Object.prototype', function(){
return Object.getPrototypeOf(Object.prototype) === null;
});

// test keys
tester.assertTrue('Object.keys should loop through all keys and nothing but the keys', function () {
var test, ref, keys, result, key;
Expand Down

0 comments on commit 18e726a

Please sign in to comment.