Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js |
— | — | @@ -186,7 +186,12 @@ |
187 | 187 | |
188 | 188 | if ( startInside && endInside ) { |
189 | 189 | // The range is entirely inside this.children[i] |
190 | | - if ( shallow ) { |
| 190 | + if ( shallow || !this.children[i].children ) { |
| 191 | + // For leaf nodes, use the same behavior as for shallow calls. |
| 192 | + // A proper recursive function would let the recursion handle this, |
| 193 | + // but the leaves don't have .selectNodes() because they're not DocumentBranchNodes |
| 194 | + // FIXME get rid of this crazy branch-specificity |
| 195 | + // TODO should probably rewrite this recursive function as an iterative function anyway, probably faster |
191 | 196 | nodes = [ |
192 | 197 | { |
193 | 198 | 'node': this.children[i], |