Added ve.getObjectKeys which falls back to Object.keys if present

Change-Id: I9eedf93239b22497fe6fe6497e20b1fe0525de9c
This commit is contained in:
Trevor Parscal 2012-05-14 11:14:54 -07:00
parent e05863b0dc
commit 1363e7ff89

View file

@ -75,6 +75,28 @@ ve.inArray = $.inArray;
*/
ve.getHash = $.toJson;
/**
* Gets an array of all property names in an object.
*
* This falls back to the native impelentation of Object.keys if available.
*
* @static
* @method
* @param {Object} Object to get properties from
* @returns {String[]} List of object keys
*/
ve.getObjectKeys = Object.keys || function( obj ) {
var keys = [],
key,
hop = Object.prototype.hasOwnProperty;
for ( key in obj ) {
if ( hop.call( obj, key ) ) {
keys.push( key );
}
}
return keys;
};
/**
* Recursively compares string and number property between two objects.
*