r103159 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103158‎ | r103159 | r103160 >
Date:12:54, 15 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
Add a wrapper for Array.prototype.indexOf(), needed for my traverseLeafNodes() rewrite
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/es.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/es.js
@@ -49,6 +49,23 @@
5050 es.isArray = $.isArray;
5151
5252 /**
 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+/**
5370 * Recursively compares string and number property between two objects.
5471 *
5572 * A false result may be caused by property inequality or by properties in one object missing from

Status & tagging log