Index: trunk/parsers/wikidom/lib/hype/bases/es.DocumentNode.js |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | * |
104 | 104 | * @method |
105 | 105 | * @param {es.Range} range Range to select nodes within |
106 | | - * @param {Boolean} [shallow] Do not iterate into child nodes of child nodes |
| 106 | + * @param {Boolean} [shallow] Do not recurse into child nodes of child nodes |
107 | 107 | * @returns {Array} List of objects with 'node' and 'range' properties describing nodes which are |
108 | 108 | * covered by the range and the range within the node that is covered |
109 | 109 | */ |
— | — | @@ -158,11 +158,16 @@ |
159 | 159 | startInside = start >= left && start <= right; // is the start inside this[i]? |
160 | 160 | endInside = end >= left && end <= right; // is the end inside this[i]? |
161 | 161 | |
162 | | - if ( !shallow && startInside && endInside ) { |
| 162 | + if ( startInside && endInside ) { |
163 | 163 | // The range is entirely inside this[i] |
164 | | - // Recurse into this[i] |
| 164 | + if ( shallow ) { |
| 165 | + nodes = [ { 'node': this[i], 'range': new es.Range( start - left, end - left ) } ]; |
| 166 | + } else { |
| 167 | + // Recurse into this[i] |
| 168 | + nodes = this[i].selectNodes( new es.Range( start - left, end - left ) ); |
| 169 | + } |
165 | 170 | // Since the start and end are both inside this[i], we know for sure that we're done, so return |
166 | | - return this[i].selectNodes( new es.Range( start - left, end - left ) ); |
| 171 | + return nodes; |
167 | 172 | } else if ( startInside ) { |
168 | 173 | // The start is inside this[i] but the end isn't |
169 | 174 | // Add a range from the start of the range to the end of this[i] |