Change 'leaf' to 'leaves' and document it

Change-Id: I09d5995d3d9bf82670802f0efe849f40be2a18a3
This commit is contained in:
Catrope 2012-05-07 16:04:19 -07:00
parent 770775eec0
commit 32c65cdaa8
2 changed files with 4 additions and 3 deletions

View file

@ -70,7 +70,8 @@ ve.dm.Document.prototype.rebuildNodes = function( parent, index, numNodes, offse
*
* @method
* @param {ve.Range} range Range within document to select nodes
* @param {String} [mode='leaf'] Type of selection to perform, currently only 'leaf' is supported
* @param {String} [mode='leaves'] Type of selection to perform, currently only 'leaves' is supported
* 'leaves': Return all leaf nodes in the given range
* @returns {Array} List of objects describing nodes in the selection and the ranges therein
* @throws 'Invalid start offset' if range.start is out of range
* @throws 'Invalid end offset' if range.end is out of range
@ -93,7 +94,7 @@ ve.dm.Document.prototype.selectNodes = function( range, mode ) {
endBetween;
// TODO needs more modes, probably. Current implementation is only for mode == 'leaf'
if ( mode && mode !== 'leaf') {
if ( mode && mode !== 'leaves' ) {
throw 'Invalid mode: ' + mode;
}

View file

@ -39,7 +39,7 @@ test( 'selectNodes', 14, function() {
// Test count: ( 1 test + ( 2 tests x 2 results ) ) = 5
ve.dm.example.nodeSelectionEqual(
doc.selectNodes( new ve.Range( 0, 10 ) ),
doc.selectNodes( new ve.Range( 0, 10 ), 'leaves' ),
[
// heading/text
{ 'node': lookup( documentNode, 0, 0 ) },