mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Added ve.getObjectKeys which falls back to Object.keys if present
Change-Id: I9eedf93239b22497fe6fe6497e20b1fe0525de9c
This commit is contained in:
parent
e05863b0dc
commit
1363e7ff89
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue