Calling hasOwnProperty via Object prototype in case it has been overridden
parent
bba0c252f5
commit
e1d7b80d46
11
lib/util.js
11
lib/util.js
|
@ -132,12 +132,13 @@ exports.clone = function( data )
|
|||
}
|
||||
else if ( data instanceof Object )
|
||||
{
|
||||
var newobj = {};
|
||||
var newobj = {},
|
||||
hasOwn = Object.prototype.hasOwnProperty;
|
||||
|
||||
// copy data to the new object
|
||||
for ( prop in data )
|
||||
{
|
||||
if ( data.hasOwnProperty( prop ) )
|
||||
if ( hasOwn.call( data, prop ) )
|
||||
{
|
||||
newobj[ prop ] = data[ prop ];
|
||||
}
|
||||
|
@ -167,14 +168,16 @@ exports.propParse = function( data, options )
|
|||
callback_prop = options.property || fvoid,
|
||||
callback_method = options.method || fvoid,
|
||||
callback_getter = options.getter || fvoid,
|
||||
callback_setter = options.setter || fvoid;
|
||||
callback_setter = options.setter || fvoid,
|
||||
|
||||
hasOwn = Object.prototype.hasOwnProperty;
|
||||
|
||||
// for each of the given properties, determine what type of property we're
|
||||
// dealing with (in the classic OO sense)
|
||||
for ( prop in data )
|
||||
{
|
||||
// ignore properties of instance prototypes
|
||||
if ( !( data.hasOwnProperty( prop ) ) )
|
||||
if ( !( hasOwn.call( data, prop ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue