r98337 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98336‎ | r98337 | r98338 >
Date:17:30, 28 September 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Code fixes!
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/bases/es.ModelList.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
@@ -25,11 +25,11 @@
2626
2727 /* Methods */
2828
29 -es.DocumentModel.prototype.findElement = function( node, root, callback ) {
 29+es.DocumentModel.prototype.findElement = function( node, root ) {
3030 for ( var i = 0; i < this.data.length; i++ ) {
3131 if ( es.DocumentModel.isElement( this.data[i] ) ) {
3232 if ( content.node === node ) {
33 - return callback( i );
 33+ return i;
3434 }
3535 // If we are looking for a root node, we can skip over the contents of this one
3636 if ( root ) {
@@ -49,9 +49,11 @@
5050 * @returns {Object|null} Element object
5151 */
5252 es.DocumentModel.prototype.getElement = function( node, root ) {
53 - return this.findNode( node, root, function( index ) {
 53+ var index = this.findNode( node, root );
 54+ if ( index !== null ) {
5455 return this.data[index];
55 - } );
 56+ }
 57+ return null;
5658 };
5759
5860 /**
@@ -63,9 +65,11 @@
6466 * @returns {Array|null} List of content and elements inside node or null if node is not found
6567 */
6668 es.DocumentModel.prototype.getContent = function( node, root ) {
67 - return this.findNode( node, root, function( index ) {
 69+ var index = this.findNode( node, root );
 70+ if ( index !== null ) {
6871 return this.data.slice( index + 1, index + node.getContentLength() );
69 - } );
 72+ }
 73+ return null;
7074 };
7175
7276 /**
Index: trunk/parsers/wikidom/lib/hype/bases/es.ModelList.js
@@ -161,7 +161,7 @@
162162 es.ModelList.prototype.sort = function( sortfunc ) {
163163 this.emit( 'sort' );
164164 this.emit( 'update' );
165 - Array.prototype.reverse.call( this );
 165+ Array.prototype.sort.call( this );
166166 };
167167
168168 /**

Status & tagging log