r103465 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103464‎ | r103465 | r103466 >
Date:14:50, 17 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
Make selectNodes() not return an empty array when encountering a zero-length selection in a structural location (we don't do this for zero-length selections in content locations either, and the empty array is breaking an assumption I was making in my prepareRemoval rewrite)
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js (modified) (history)
  • /trunk/extensions/VisualEditor/tests/es/es.DocumentBranchNode.test.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/es/es.DocumentBranchNode.test.js
@@ -167,7 +167,7 @@
168168 {
169169 'node': root2,
170170 'input': new es.Range( 0, 0 ),
171 - 'output': [],
 171+ 'output': [{ 'node': root2, 'range': new es.Range( 0, 0 ), 'globalRange': new es.Range( 0, 0 ) }],
172172 'desc': 'Zero-length range before the beginning of a node'
173173 },
174174 // Test 2
@@ -272,14 +272,14 @@
273273 {
274274 'node': root2,
275275 'input': new es.Range( 30, 30 ),
276 - 'output': [],
 276+ 'output': [{ 'node': root2, 'range': new es.Range( 30, 30 ), 'globalRange': new es.Range( 30, 30 ) }],
277277 'desc': 'Zero-length range past the end of a node'
278278 },
279279 // Test 17
280280 {
281281 'node': root2,
282282 'input': new es.Range( 20, 20 ),
283 - 'output': [],
 283+ 'output': [{ 'node': root2, 'range': new es.Range( 20, 20 ), 'globalRange': new es.Range( 20, 20 ) }],
284284 'desc': 'Zero-length range between two nodes'
285285 },
286286
Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js
@@ -325,7 +325,7 @@
326326
327327 if ( start == end && ( start == left - 1 || start == right + 1 ) ) {
328328 // Empty range outside of any node
329 - return [];
 329+ return [{ 'node': this, 'range': new es.Range( start, end ), 'globalRange': new es.Range( start, end ) }];
330330 }
331331
332332 startInside = start >= left && start <= right; // is the start inside childNode?

Status & tagging log