__proto__ => getPrototypeOf
parent
94419742c0
commit
80846e95f3
17
lib/util.js
17
lib/util.js
|
@ -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
|
* Travels down the prototype chain of the given object in search of the
|
||||||
* requested property and returns its descriptor
|
* 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
|
// note that this uses util's function, not Object's
|
||||||
var desc = exports.getOwnPropertyDescriptor( obj, prop ),
|
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
|
// 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 prototype chain, ensuring that the next prototype has a prototype if
|
||||||
// the base is to be excluded
|
// 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
|
// return the descriptor or undefined if no prototype is available
|
||||||
|
@ -505,7 +514,7 @@ exports.getPropertyDescriptor = function( obj, prop, nobase )
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
exports.defineSecureProp( exports.getPropertyDescriptor, 'canTraverse',
|
exports.defineSecureProp( exports.getPropertyDescriptor, 'canTraverse',
|
||||||
( {}.__proto__ ) ? true : false
|
( Object.getPrototypeOf ) ? true : false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue