Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js |
— | — | @@ -35,6 +35,17 @@ |
36 | 36 | }; |
37 | 37 | |
38 | 38 | /** |
| 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 | +/** |
39 | 50 | * Traverse leaf nodes depth first. |
40 | 51 | * |
41 | 52 | * Callback functions are expected to accept a node and index argument. If a callback returns false, |
— | — | @@ -70,7 +81,7 @@ |
71 | 82 | throw "from parameter passed to traverseLeafNodes() must be a descendant"; |
72 | 83 | } |
73 | 84 | // Find the index of n in p |
74 | | - i = es.arrayIndexOf( p.getChildren(), n ); |
| 85 | + i = p.getChildren().indexOf( n ); |
75 | 86 | if ( i === -1 ) { |
76 | 87 | // This isn't supposed to be possible |
77 | 88 | 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 @@ |
203 | 203 | }; |
204 | 204 | |
205 | 205 | /** |
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 | | -/** |
217 | 206 | * Sets the root node to this and all of it's children. |
218 | 207 | * |
219 | 208 | * @method |