r102653 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102652‎ | r102653 | r102654 >
Date:13:51, 10 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
Fix selectNodes(), can't recurse into leaf nodes because they aren't DocumentBranchNodes and don't have the selectNodes function. The pattern of certain functions just not existing for leaf nodes is starting to annoy me, I'll discuss this with Trevor.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js
@@ -186,7 +186,12 @@
187187
188188 if ( startInside && endInside ) {
189189 // 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
191196 nodes = [
192197 {
193198 'node': this.children[i],

Status & tagging log