1
0
Fork 0

Calling hasOwnProperty via Object prototype in case it has been overridden

closure/master
Mike Gerwitz 2010-12-21 10:09:18 -05:00
parent bba0c252f5
commit e1d7b80d46
1 changed files with 7 additions and 4 deletions

View File

@ -132,12 +132,13 @@ exports.clone = function( data )
} }
else if ( data instanceof Object ) else if ( data instanceof Object )
{ {
var newobj = {}; var newobj = {},
hasOwn = Object.prototype.hasOwnProperty;
// copy data to the new object // copy data to the new object
for ( prop in data ) for ( prop in data )
{ {
if ( data.hasOwnProperty( prop ) ) if ( hasOwn.call( data, prop ) )
{ {
newobj[ prop ] = data[ prop ]; newobj[ prop ] = data[ prop ];
} }
@ -167,14 +168,16 @@ exports.propParse = function( data, options )
callback_prop = options.property || fvoid, callback_prop = options.property || fvoid,
callback_method = options.method || fvoid, callback_method = options.method || fvoid,
callback_getter = options.getter || 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 // for each of the given properties, determine what type of property we're
// dealing with (in the classic OO sense) // dealing with (in the classic OO sense)
for ( prop in data ) for ( prop in data )
{ {
// ignore properties of instance prototypes // ignore properties of instance prototypes
if ( !( data.hasOwnProperty( prop ) ) ) if ( !( hasOwn.call( data, prop ) ) )
{ {
continue; continue;
} }