Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object.getPrototypeOf should return null when the parameter is Object.prototype #26

Merged
merged 1 commit into from Jul 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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