r103203 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103202‎ | r103203 | r103204 >
Date:18:17, 15 November 2011
Author:tparscal
Status:ok
Tags:
Comment:
Fixed documentation and use of es.arrayIndexOf to match the actual API of $.inArray (value, array, fromIndex). Renamed function to inArray to reduce confusion about how the function works.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/bases/es.EventEmitter.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/es.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.ContentView.js (modified) (history)
  • /trunk/extensions/VisualEditor/tests/es/es.TransactionProcessor.test.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/es/es.TransactionProcessor.test.js
@@ -175,7 +175,9 @@
176176 'rollback keeps model tree up to date with removals'
177177 );
178178
179 - var paragraphBreak = documentModel.prepareInsertion( 2, [ { 'type': '/paragraph' }, { 'type': 'paragraph' } ] );
 179+ var paragraphBreak = documentModel.prepareInsertion(
 180+ 2, [{ 'type': '/paragraph' }, { 'type': 'paragraph' }]
 181+ );
180182
181183 // Test 13
182184 es.TransactionProcessor.commit( documentModel, paragraphBreak );
@@ -192,7 +194,7 @@
193195 ],
194196 'commit applies an insertion transaction that splits the paragraph'
195197 );
196 -
 198+
197199 // Test 14
198200 deepEqual(
199201 documentModel.getChildren()[0].getContent(),
@@ -223,7 +225,7 @@
224226 ],
225227 'rollback reverses the effect of a paragraph split on the content'
226228 );
227 -
 229+
228230 // Test 17
229231 deepEqual(
230232 documentModel.getChildren()[0].getContent(),
Index: trunk/extensions/VisualEditor/modules/es/es.js
@@ -51,11 +51,12 @@
5252 /**
5353 * Wrapper for Array.prototype.indexOf
5454 *
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 ===
 55+ * @param {Mixed} value Element to search for
 56+ * @param {Array} array Array to search in
 57+ * @param {Integer} [fromIndex=0] Index to being searching from
 58+ * @return {Number} Index of value in array, or -1 if not found. Comparisons are done with ===
5859 */
59 -es.arrayIndexOf = $.inArray;
 60+es.inArray = $.inArray;
6061
6162 /**
6263 * Recursively compares string and number property between two objects.
Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js
@@ -42,7 +42,7 @@
4343 * @returns {Integer} Index of child node or -1 if node was not found
4444 */
4545 es.DocumentBranchNode.prototype.indexOf = function( node ) {
46 - return es.arrayIndexOf( this.children, node );
 46+ return es.inArray( node, this.children );
4747 };
4848
4949 /**
Index: trunk/extensions/VisualEditor/modules/es/bases/es.EventEmitter.js
@@ -148,7 +148,7 @@
149149 if ( handlers.length === 1 && handlers[0] === listener ) {
150150 delete this.events[type];
151151 } else {
152 - var i = es.arrayIndexOf( handlers, listener );
 152+ var i = es.inArray( listener, handlers );
153153 if ( i < 0 ) {
154154 return this;
155155 }
Index: trunk/extensions/VisualEditor/modules/es/views/es.ContentView.js
@@ -180,7 +180,7 @@
181181 renderers[type].close( annotation.data ) : renderers[type].close;
182182 } else {
183183 // Find the annotation in the stack
184 - var depth = es.arrayIndexOf( stack, annotation ),
 184+ var depth = es.inArray( annotation, stack ),
185185 i;
186186 if ( depth === -1 ) {
187187 throw 'Invalid stack error. An element is missing from the stack.';

Status & tagging log