r103201 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103200‎ | r103201 | r103202 >
Date:17:54, 15 November 2011
Author:tparscal
Status:deferred (Comments)
Tags:
Comment:
Using jQuery.inArray implementation of indexOf instead of our own
Fixed a wrong class name bug
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/es.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/es.js
@@ -55,15 +55,7 @@
5656 * @param elem {Mixed} Element to search for
5757 * @return {Number} Index of elem in arr, or -1 if not found. Comparisons are done with ===
5858 */
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 -};
 59+es.arrayIndexOf = $.inArray;
6860
6961 /**
7062 * Recursively compares string and number property between two objects.
Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js
@@ -41,7 +41,7 @@
4242 * @param {es.DocumentModelNode} node Child node to find index of
4343 * @returns {Integer} Index of child node or -1 if node was not found
4444 */
45 -es.DocumentModelBranchNode.prototype.indexOf = function( node ) {
 45+es.DocumentBranchNode.prototype.indexOf = function( node ) {
4646 return es.arrayIndexOf( this.children, node );
4747 };
4848

Comments

#Comment by Lupo (talk | contribs)   08:04, 16 November 2011

Isn't the parameter order swapped? $.inArray (element, array) vs. Roan's es.arrayIndexOf (array, element)?

Calls of es.arrayIndexOf() need to be updated now.

#Comment by Catrope (talk | contribs)   08:06, 16 November 2011

Fixed in r103203.

Status & tagging log