Index: trunk/extensions/VisualEditor/modules/es/es.js |
— | — | @@ -49,6 +49,23 @@ |
50 | 50 | es.isArray = $.isArray; |
51 | 51 | |
52 | 52 | /** |
| 53 | + * Wrapper for Array.prototype.indexOf |
| 54 | + * |
| 55 | + * @param arr {Array} Array to search in |
| 56 | + * @param elem {Mixed} Element to search for |
| 57 | + * @return {Number} Index of elem in arr, or -1 if not found. Comparisons are done with === |
| 58 | + */ |
| 59 | +es.arrayIndexOf = Array.prototype.indexOf ? function( arr, elem ) { return arr.indexOf( elem ); } : function( arr, elem ) { |
| 60 | + var i; |
| 61 | + for ( i = 0; i < arr.length; i++ ) { |
| 62 | + if ( arr[i] === elem ) { |
| 63 | + return i; |
| 64 | + } |
| 65 | + } |
| 66 | + return -1; |
| 67 | +}; |
| 68 | + |
| 69 | +/** |
53 | 70 | * Recursively compares string and number property between two objects. |
54 | 71 | * |
55 | 72 | * A false result may be caused by property inequality or by properties in one object missing from |