r98841 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98840‎ | r98841 | r98842 >
Date:00:31, 4 October 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Fixed off-by-one error in tree building
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js (modified) (history)
  • /trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js
@@ -177,8 +177,31 @@
178178 { 'type': '/paragraph' }
179179 ];
180180
 181+/**
 182+ * Sample content data index.
 183+ *
 184+ * This is a node tree that describes each partition within the document's content data.
 185+ */
 186+var tree = [
 187+ new es.ParagraphModel( 3 ),
 188+ new es.TableModel( [
 189+ new es.TableRowModel( [
 190+ new es.TableCellModel( [
 191+ new es.ParagraphModel( 1 ),
 192+ new es.ListModel( [
 193+ new es.ListItemModel( 1 ),
 194+ new es.ListItemModel( 1 ),
 195+ new es.ListItemModel( 1 )
 196+ ] )
 197+ ] )
 198+ ] )
 199+ ] ),
 200+ new es.ParagraphModel( 1 )
 201+];
 202+
181203 test( 'es.DocumentModel', function() {
182204 var documentModel = es.DocumentModel.newFromPlainObject( obj );
183205
184206 deepEqual( documentModel.getData(), data, 'Flattening plain objects results in correct data' );
 207+ deepEqual( documentModel.slice( 0 ), tree, 'Nodes contain correct lengths' );
185208 } );
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
@@ -224,6 +224,7 @@
225225 i++;
226226 }
227227 currentNode.setContentLength( i - start );
 228+ i--;
228229 }
229230 }
230231 };

Status & tagging log