r103185 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103184‎ | r103185 | r103186 >
Date:16:24, 15 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
Move .indexOf() from es.DocumentModelBranchNode to es.DocumentBranchNode and use it in .traverseLeafNodes()
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js
@@ -35,6 +35,17 @@
3636 };
3737
3838 /**
 39+ * Gets the index of a given child node.
 40+ *
 41+ * @method
 42+ * @param {es.DocumentModelNode} node Child node to find index of
 43+ * @returns {Integer} Index of child node or -1 if node was not found
 44+ */
 45+es.DocumentModelBranchNode.prototype.indexOf = function( node ) {
 46+ return es.arrayIndexOf( this.children, node );
 47+};
 48+
 49+/**
3950 * Traverse leaf nodes depth first.
4051 *
4152 * Callback functions are expected to accept a node and index argument. If a callback returns false,
@@ -70,7 +81,7 @@
7182 throw "from parameter passed to traverseLeafNodes() must be a descendant";
7283 }
7384 // Find the index of n in p
74 - i = es.arrayIndexOf( p.getChildren(), n );
 85+ i = p.getChildren().indexOf( n );
7586 if ( i === -1 ) {
7687 // This isn't supposed to be possible
7788 throw "Tree corruption detected: node isn't in its parent's children array";
Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentModelBranchNode.js
@@ -202,17 +202,6 @@
203203 };
204204
205205 /**
206 - * Gets the index of a given child node.
207 - *
208 - * @method
209 - * @param {es.DocumentModelNode} node Child node to find index of
210 - * @returns {Integer} Index of child node or -1 if node was not found
211 - */
212 -es.DocumentModelBranchNode.prototype.indexOf = function( node ) {
213 - return es.arrayIndexOf( this.children, node );
214 -};
215 -
216 -/**
217206 * Sets the root node to this and all of it's children.
218207 *
219208 * @method

Status & tagging log