Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -25,11 +25,11 @@ |
26 | 26 | |
27 | 27 | /* Methods */ |
28 | 28 | |
29 | | -es.DocumentModel.prototype.findElement = function( node, root, callback ) { |
| 29 | +es.DocumentModel.prototype.findElement = function( node, root ) { |
30 | 30 | for ( var i = 0; i < this.data.length; i++ ) { |
31 | 31 | if ( es.DocumentModel.isElement( this.data[i] ) ) { |
32 | 32 | if ( content.node === node ) { |
33 | | - return callback( i ); |
| 33 | + return i; |
34 | 34 | } |
35 | 35 | // If we are looking for a root node, we can skip over the contents of this one |
36 | 36 | if ( root ) { |
— | — | @@ -49,9 +49,11 @@ |
50 | 50 | * @returns {Object|null} Element object |
51 | 51 | */ |
52 | 52 | 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 ) { |
54 | 55 | return this.data[index]; |
55 | | - } ); |
| 56 | + } |
| 57 | + return null; |
56 | 58 | }; |
57 | 59 | |
58 | 60 | /** |
— | — | @@ -63,9 +65,11 @@ |
64 | 66 | * @returns {Array|null} List of content and elements inside node or null if node is not found |
65 | 67 | */ |
66 | 68 | 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 ) { |
68 | 71 | return this.data.slice( index + 1, index + node.getContentLength() ); |
69 | | - } ); |
| 72 | + } |
| 73 | + return null; |
70 | 74 | }; |
71 | 75 | |
72 | 76 | /** |
Index: trunk/parsers/wikidom/lib/hype/bases/es.ModelList.js |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | es.ModelList.prototype.sort = function( sortfunc ) { |
163 | 163 | this.emit( 'sort' ); |
164 | 164 | this.emit( 'update' ); |
165 | | - Array.prototype.reverse.call( this ); |
| 165 | + Array.prototype.sort.call( this ); |
166 | 166 | }; |
167 | 167 | |
168 | 168 | /** |