1
0
Fork 0

__proto__ => getPrototypeOf

closure/master
Mike Gerwitz 2011-11-18 23:14:40 -05:00
parent 94419742c0
commit 80846e95f3
1 changed files with 13 additions and 4 deletions

View File

@ -457,6 +457,15 @@ exports.getOwnPropertyDescriptor =
};
/**
* Returns prototype of object, or undefined if unsupported
*/
exports.getPrototypeOf = Object.getPrototypeOf || function()
{
return undefined;
};
/**
* Travels down the prototype chain of the given object in search of the
* requested property and returns its descriptor
@ -483,14 +492,14 @@ exports.getPropertyDescriptor = function( obj, prop, nobase )
// note that this uses util's function, not Object's
var desc = exports.getOwnPropertyDescriptor( obj, prop ),
next = obj.__proto__;
next = exports.getPrototypeOf( obj );
// if we didn't find a descriptor and a prototype is available, recurse down
// the prototype chain, ensuring that the next prototype has a prototype if
// the base is to be excluded
if ( !desc && next && ( !nobase || next.__proto__ ) )
if ( !desc && next && ( !nobase || exports.getPrototypeOf( next ) ) )
{
return exports.getPropertyDescriptor( obj.__proto__, prop, nobase );
return exports.getPropertyDescriptor( next, prop, nobase );
}
// return the descriptor or undefined if no prototype is available
@ -505,7 +514,7 @@ exports.getPropertyDescriptor = function( obj, prop, nobase )
* @type {boolean}
*/
exports.defineSecureProp( exports.getPropertyDescriptor, 'canTraverse',
( {}.__proto__ ) ? true : false
( Object.getPrototypeOf ) ? true : false
);