Procházet zdrojové kódy

Renamed `FORWARD` and `BACKWARD` to lower case.

Oskar Wrobel před 9 roky
rodič
revize
7dbf9458d4

+ 3 - 3
packages/ckeditor5-engine/src/model/composer/modifyselection.js

@@ -19,16 +19,16 @@ import Range from '../range.js';
  * @method engine.model.composer.modifySelection
  * @param {engine.model.Selection} The selection to modify.
  * @param {Object} [options]
- * @param {'FORWARD'|'BACKWARD'} [options.direction='FORWARD'] The direction in which the selection should be modified.
+ * @param {'forward'|'backward'} [options.direction='forward'] The direction in which the selection should be modified.
  */
 export default function modifySelection( selection, options = {} ) {
-	const isForward = options.direction != 'BACKWARD';
+	const isForward = options.direction != 'backward';
 
 	const focus = selection.focus;
 	const walker = new TreeWalker( {
 		boundaries: getSearchRange( focus, isForward ),
 		singleCharacters: true,
-		direction: isForward ? 'FORWARD' : 'BACKWARD'
+		direction: isForward ? 'forward' : 'backward'
 	} );
 
 	let next = walker.next();

+ 12 - 12
packages/ckeditor5-engine/src/model/treewalker.js

@@ -22,7 +22,7 @@ export default class TreeWalker {
 	 *
 	 * @constructor
 	 * @param {Object} [options={}] Object with configuration.
-	 * @param {'FORWARD'|'BACKWARD'} [options.direction='FORWARD'] Walking direction.
+	 * @param {'forward'|'backward'} [options.direction='forward'] Walking direction.
 	 * @param {engine.model.Range} [options.boundaries=null] Range to define boundaries of the iterator.
 	 * @param {engine.model.Position} [options.startPosition] Starting position.
 	 * @param {Boolean} [options.singleCharacters=false] Flag indicating whether all consecutive characters with the same attributes
@@ -45,27 +45,27 @@ export default class TreeWalker {
 			throw new CKEditorError( 'tree-walker-no-start-position: Neither boundaries nor starting position have been defined.' );
 		}
 
-		const direction = options.direction || 'FORWARD';
+		const direction = options.direction || 'forward';
 
-		if ( direction != 'FORWARD' && direction != 'BACKWARD' ) {
+		if ( direction != 'forward' && direction != 'backward' ) {
 			throw new CKEditorError(
-				'tree-walker-unknown-direction: Only `BACKWARD` and `FORWARD` direction allowed.',
+				'tree-walker-unknown-direction: Only `backward` and `forward` direction allowed.',
 				{ direction }
 			);
 		}
 
 		/**
-		 * Walking direction. Defaults `FORWARD`.
+		 * Walking direction. Defaults `'forward'`.
 		 *
 		 * @readonly
-		 * @member {'BACKWARD'|'FORWARD'} engine.model.TreeWalker#direction
+		 * @member {'backward'|'forward'} engine.model.TreeWalker#direction
 		 */
 		this.direction = direction;
 
 		/**
 		 * Iterator boundaries.
 		 *
-		 * When the iterator is walking `FORWARD` on the end of boundary or is walking `BACKWARD`
+		 * When the iterator is walking `'forward'` on the end of boundary or is walking `'backward'`
 		 * on the start of boundary, then `{ done: true }` is returned.
 		 *
 		 * If boundaries are not defined they are set before first and after last child of the root node.
@@ -78,8 +78,8 @@ export default class TreeWalker {
 		/**
 		 * Iterator position. This is always static position, even if the initial position was a
 		 * {@link engine.model.LivePosition live position}. If start position is not defined then position depends
-		 * on {@link #direction}. If direction is `FORWARD` position starts form the beginning, when direction
-		 * is `BACKWARD` position starts from the end.
+		 * on {@link #direction}. If direction is `'forward'` position starts form the beginning, when direction
+		 * is `'backward'` position starts from the end.
 		 *
 		 * @readonly
 		 * @member {engine.model.Position} engine.model.TreeWalker#position
@@ -87,7 +87,7 @@ export default class TreeWalker {
 		if ( options.startPosition ) {
 			this.position = Position.createFromPosition( options.startPosition );
 		} else {
-			this.position = Position.createFromPosition( this.boundaries[ this.direction == 'BACKWARD' ? 'end' : 'start' ] );
+			this.position = Position.createFromPosition( this.boundaries[ this.direction == 'backward' ? 'end' : 'start' ] );
 		}
 
 		/**
@@ -158,7 +158,7 @@ export default class TreeWalker {
 	 * @returns {Object} Object implementing iterator interface, returning information about taken step.
 	 */
 	next() {
-		if ( this.direction == 'FORWARD' ) {
+		if ( this.direction == 'forward' ) {
 			return this._next();
 		} else {
 			return this._previous();
@@ -364,5 +364,5 @@ function formatReturnValue( type, item, previousPosition, nextPosition, length )
 /**
  * Tree walking directions.
  *
- * @typedef {'FORWARD'|'BACKWARD'} engine.view.TreeWalkerDirection
+ * @typedef {'forward'|'backward'} engine.view.TreeWalkerDirection
  */

+ 13 - 13
packages/ckeditor5-engine/src/view/treewalker.js

@@ -24,7 +24,7 @@ export default class TreeWalker {
 	 * @param {Object} options Object with configuration.
 	 * @param {engine.view.Range} [options.boundaries=null] Range to define boundaries of the iterator.
 	 * @param {engine.view.Position} [options.startPosition] Starting position.
-	 * @param {'FORWARD'|'BACKWARD'} [options.direction='FORWARD'] Walking direction.
+	 * @param {'forward'|'backward'} [options.direction='forward'] Walking direction.
 	 * @param {Boolean} [options.singleCharacters=false] Flag indicating whether all characters from
 	 * {@link engine.view.Text} should be returned as one {@link engine.view.Text} (`false`) ore one by one as
 	 * {@link engine.view.TextProxy} (`true`).
@@ -45,9 +45,9 @@ export default class TreeWalker {
 			throw new CKEditorError( 'tree-walker-no-start-position: Neither boundaries nor starting position have been defined.' );
 		}
 
-		if ( options.direction && options.direction != 'FORWARD' && options.direction != 'BACKWARD' ) {
+		if ( options.direction && options.direction != 'forward' && options.direction != 'backward' ) {
 			throw new CKEditorError(
-				'tree-walker-unknown-direction: Only `BACKWARD` and `FORWARD` direction allowed.',
+				'tree-walker-unknown-direction: Only `backward` and `forward` direction allowed.',
 				{ direction: options.direction }
 			);
 		}
@@ -55,7 +55,7 @@ export default class TreeWalker {
 		/**
 		 * Iterator boundaries.
 		 *
-		 * When the iterator is walking `FORWARD` on the end of boundary or is walking `BACKWARD`
+		 * When the iterator is walking `'forward'` on the end of boundary or is walking `'backward'`
 		 * on the start of boundary, then `{ done: true }` is returned.
 		 *
 		 * If boundaries are not defined they are set before first and after last child of the root node.
@@ -67,7 +67,7 @@ export default class TreeWalker {
 
 		/**
 		 * Iterator position. If start position is not defined then position depends on {@link #direction}. If direction is
-		 * `FORWARD` position starts form the beginning, when direction is `BACKWARD` position starts from the end.
+		 * `'forward'` position starts form the beginning, when direction is `'backward'` position starts from the end.
 		 *
 		 * @readonly
 		 * @member {engine.view.Position} engine.view.TreeWalker#position
@@ -75,16 +75,16 @@ export default class TreeWalker {
 		if ( options.startPosition ) {
 			this.position = Position.createFromPosition( options.startPosition );
 		} else {
-			this.position = Position.createFromPosition( options.boundaries[ options.direction == 'BACKWARD' ? 'end' : 'start' ] );
+			this.position = Position.createFromPosition( options.boundaries[ options.direction == 'backward' ? 'end' : 'start' ] );
 		}
 
 		/**
-		 * Walking direction. Defaults `FORWARD`.
+		 * Walking direction. Defaults `'forward'`.
 		 *
 		 * @readonly
-		 * @member {'BACKWARD'|'FORWARD'} engine.view.TreeWalker#direction
+		 * @member {'backward'|'forward'} engine.view.TreeWalker#direction
 		 */
-		this.direction = options.direction || 'FORWARD';
+		this.direction = options.direction || 'forward';
 
 		/**
 		 * Flag indicating whether all characters from {@link engine.view.Text} should be returned as one
@@ -145,7 +145,7 @@ export default class TreeWalker {
 	 * @returns {Object} Object implementing iterator interface, returning information about taken step.
 	 */
 	next() {
-		if ( this.direction == 'FORWARD' ) {
+		if ( this.direction == 'forward' ) {
 			return this._next();
 		} else {
 			return this._previous();
@@ -372,7 +372,7 @@ export default class TreeWalker {
 		if ( item instanceof TextProxy ) {
 			// Position is at the end of Text.
 			if ( item.index + item.data.length == item.textNode.data.length ) {
-				if ( this.direction == 'FORWARD' ) {
+				if ( this.direction == 'forward' ) {
 					nextPosition = Position.createAfter( item.textNode );
 					// When we change nextPosition of returned value we need also update walker current position.
 					this.position = nextPosition;
@@ -383,7 +383,7 @@ export default class TreeWalker {
 
 			// Position is at the begining ot the text.
 			if ( item.index === 0 ) {
-				if ( this.direction == 'FORWARD' ) {
+				if ( this.direction == 'forward' ) {
 					previousPosition = Position.createBefore( item.textNode );
 				} else {
 					nextPosition = Position.createBefore( item.textNode );
@@ -443,5 +443,5 @@ export default class TreeWalker {
 /**
  * Tree walking directions.
  *
- * @typedef {'FORWARD'|'BACKWARD'} engine.view.TreeWalkerDirection
+ * @typedef {'forward'|'backward'} engine.view.TreeWalkerDirection
  */

+ 1 - 1
packages/ckeditor5-engine/tests/model/composer/composer.js

@@ -53,7 +53,7 @@ describe( 'Composer', () => {
 			composer.fire( 'modifySelection', {
 				selection: document.selection,
 				options: {
-					direction: 'BACKWARD'
+					direction: 'backward'
 				}
 			} );
 

+ 14 - 14
packages/ckeditor5-engine/tests/model/composer/modifyselection.js

@@ -38,7 +38,7 @@ describe( 'Delete utils', () => {
 					'does nothing on empty content (backward)',
 					'<selection />',
 					'<selection />',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -51,7 +51,7 @@ describe( 'Delete utils', () => {
 					'does nothing on root boundary (backward)',
 					'<p><selection />foo</p>',
 					'<p><selection />foo</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -64,7 +64,7 @@ describe( 'Delete utils', () => {
 					'extends one character backward',
 					'<p>fo<selection />o</p>',
 					'<p>f<selection backward>o</selection>o</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -77,7 +77,7 @@ describe( 'Delete utils', () => {
 					'extends one character backward (non-collapsed)',
 					'<p>foob<selection backward>a</selection>r</p>',
 					'<p>foo<selection backward>ba</selection>r</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -90,14 +90,14 @@ describe( 'Delete utils', () => {
 					'extends to element boundary (backward)',
 					'<p>f<selection />oo</p>',
 					'<p><selection backward>f</selection>oo</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
 					'shrinks forward selection (to collapsed)',
 					'<p>foo<selection>b</selection>ar</p>',
 					'<p>foo<selection />bar</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -122,7 +122,7 @@ describe( 'Delete utils', () => {
 					'extends one element backward',
 					'<p>fo<img></img><selection />o</p>',
 					'<p>fo<selection backward><img></img></selection>o</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 			} );
 
@@ -137,7 +137,7 @@ describe( 'Delete utils', () => {
 					'extends over boundary of empty elements (backward)',
 					'<p></p><p></p><p><selection /></p>',
 					'<p></p><p><selection backward></p><p></selection></p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -150,7 +150,7 @@ describe( 'Delete utils', () => {
 					'extends over boundary of non-empty elements (backward)',
 					'<p>a</p><p><selection />bcd</p>',
 					'<p>a<selection backward></p><p></selection>bcd</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -163,7 +163,7 @@ describe( 'Delete utils', () => {
 					'extends over character after boundary (backward)',
 					'<p>abc<selection backward></p><p></selection>d</p>',
 					'<p>ab<selection backward>c</p><p></selection>d</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -188,7 +188,7 @@ describe( 'Delete utils', () => {
 					'extends over element when next node is a text (backward)',
 					'ab<p><selection />c</p>',
 					'ab<selection backward><p></selection>c</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -201,7 +201,7 @@ describe( 'Delete utils', () => {
 					'shrinks over boundary of empty elements (backward)',
 					'<p><selection></p><p></selection></p>',
 					'<p><selection /></p><p></p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 
 				test(
@@ -214,7 +214,7 @@ describe( 'Delete utils', () => {
 					'shrinks over boundary of non-empty elements (backward)',
 					'<p>a<selection></p><p></selection>b</p>',
 					'<p>a<selection /></p><p>b</p>',
-					{ direction: 'BACKWARD' }
+					{ direction: 'backward' }
 				);
 			} );
 		} );
@@ -223,7 +223,7 @@ describe( 'Delete utils', () => {
 			'updates selection attributes',
 			'<p><$text bold=true>foo</$text><selection>b</selection></p>',
 			'<p><$text bold=true>foo</$text><selection bold=true />b</p>',
-			{ direction: 'BACKWARD' }
+			{ direction: 'backward' }
 		);
 	} );
 

+ 30 - 30
packages/ckeditor5-engine/tests/model/treewalker.js

@@ -88,7 +88,7 @@ describe( 'TreeWalker', () => {
 			];
 		} );
 
-		it( 'should provide iterator interface with default FORWARD direction', () => {
+		it( 'should provide iterator interface with default forward direction', () => {
 			let iterator = new TreeWalker( { startPosition: rootBeginning } );
 			let i = 0;
 
@@ -100,8 +100,8 @@ describe( 'TreeWalker', () => {
 			expect( i ).to.equal( expected.length );
 		} );
 
-		it( 'should provide iterator interface with FORWARD direction', () => {
-			let iterator = new TreeWalker( { startPosition: rootBeginning, direction: 'FORWARD' } );
+		it( 'should provide iterator interface with forward direction', () => {
+			let iterator = new TreeWalker( { startPosition: rootBeginning, direction: 'forward' } );
 			let i = 0;
 
 			for ( let value of iterator ) {
@@ -112,12 +112,12 @@ describe( 'TreeWalker', () => {
 			expect( i ).to.equal( expected.length );
 		} );
 
-		it( 'should provide iterator interface which BACKWARD direction', () => {
-			let iterator = new TreeWalker( { startPosition: rootEnding, direction: 'BACKWARD' } );
+		it( 'should provide iterator interface which backward direction', () => {
+			let iterator = new TreeWalker( { startPosition: rootEnding, direction: 'backward' } );
 			let i = expected.length;
 
 			for ( let value of iterator ) {
-				expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+				expectValue( value, expected[ --i ], { direction: 'backward' } );
 			}
 
 			expect( i ).to.equal( 0 );
@@ -141,11 +141,11 @@ describe( 'TreeWalker', () => {
 				{ type: 'elementEnd', item: img1 }
 			];
 
-			let iterator = new TreeWalker( { startPosition: new Position( root, [ 1 ] ), direction: 'BACKWARD' } );
+			let iterator = new TreeWalker( { startPosition: new Position( root, [ 1 ] ), direction: 'backward' } );
 			let i = expected.length;
 
 			for ( let value of iterator ) {
-				expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+				expectValue( value, expected[ --i ], { direction: 'backward' } );
 			}
 
 			expect( i ).to.equal( 0 );
@@ -181,11 +181,11 @@ describe( 'TreeWalker', () => {
 			} );
 
 			it( 'should iterating over the range going backward', () => {
-				let iterator = new TreeWalker( { boundaries: range, direction: 'BACKWARD' } );
+				let iterator = new TreeWalker( { boundaries: range, direction: 'backward' } );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -221,12 +221,12 @@ describe( 'TreeWalker', () => {
 			it( 'should return part of the text going backward', () => {
 				let iterator = new TreeWalker( {
 					boundaries: range,
-					direction: 'BACKWARD' }
+					direction: 'backward' }
 				);
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -263,12 +263,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					boundaries: range,
 					startPosition: range.end,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -311,12 +311,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					boundaries: range,
 					startPosition: new Position( root, [ 1, 4 ] ),
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -359,12 +359,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					startPosition: rootEnding,
 					singleCharacters: true,
-					direction: 'BACKWARD' }
+					direction: 'backward' }
 				);
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -404,12 +404,12 @@ describe( 'TreeWalker', () => {
 					boundaries: range,
 					singleCharacters: true,
 					startPosition: range.end,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -440,11 +440,11 @@ describe( 'TreeWalker', () => {
 		} );
 
 		it( 'should not enter elements going backward', () => {
-			let iterator = new TreeWalker( { startPosition: rootEnding, shallow: true, direction: 'BACKWARD' } );
+			let iterator = new TreeWalker( { startPosition: rootEnding, shallow: true, direction: 'backward' } );
 			let i = expected.length;
 
 			for ( let value of iterator ) {
-				expectValue( value, expected[ --i ], { shallow: true, direction: 'BACKWARD' } );
+				expectValue( value, expected[ --i ], { shallow: true, direction: 'backward' } );
 			}
 
 			expect( i ).to.equal( 0 );
@@ -482,12 +482,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					startPosition: rootEnding,
 					ignoreElementEnd: true,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -530,12 +530,12 @@ describe( 'TreeWalker', () => {
 					startPosition: rootEnding,
 					singleCharacters: true,
 					ignoreElementEnd: true,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -565,7 +565,7 @@ function expectText( value, expected, options = {} ) {
 	expect( Array.from( value.item.first._attrs ) ).to.deep.equal( expected.attrs );
 	expect( value.length ).to.equal( value.item.text.length );
 
-	if ( options.direction == 'BACKWARD' ) {
+	if ( options.direction == 'backward' ) {
 		previousPosition = Position.createAfter( value.item.last );
 		nextPosition = Position.createBefore( value.item.first );
 	} else {
@@ -584,7 +584,7 @@ function expectCharacter( value, expected, options = {} ) {
 	expect( Array.from( value.item._attrs ) ).to.deep.equal( expected.attrs );
 	expect( value.length ).to.equal( value.item.character.length );
 
-	if ( options.direction == 'BACKWARD' ) {
+	if ( options.direction == 'backward' ) {
 		previousPosition = Position.createAfter( value.item );
 		nextPosition = Position.createBefore( value.item );
 	} else {
@@ -602,7 +602,7 @@ function expectStart( value, expected, options = {} ) {
 	expect( value.item ).to.equal( expected.item );
 	expect( value.length ).to.equal( 1 );
 
-	if ( options.direction == 'BACKWARD' ) {
+	if ( options.direction == 'backward' ) {
 		previousPosition = Position.createAfter( value.item );
 		nextPosition = Position.createBefore( value.item );
 	} else {
@@ -623,7 +623,7 @@ function expectEnd( value, expected, options = {} ) {
 	expect( value.item ).to.equal( expected.item );
 	expect( value.length ).to.be.undefined;
 
-	if ( options.direction == 'BACKWARD' ) {
+	if ( options.direction == 'backward' ) {
 		previousPosition = Position.createAfter( value.item );
 		nextPosition = Position.createFromParentAndOffset( value.item, value.item.getChildCount() );
 	} else {

+ 1 - 1
packages/ckeditor5-engine/tests/tickets/475/475.js

@@ -51,7 +51,7 @@ export default class AutoLinker extends Feature {
 
 			for ( let value of changes.range.getItems( { singleCharacters: true } ) ) {
 				const walker = new TreeWalker( {
-					direction: 'BACKWARD',
+					direction: 'backward',
 					startPosition: Position.createAfter( value )
 				} );
 

+ 29 - 29
packages/ckeditor5-engine/tests/view/treewalker.js

@@ -150,7 +150,7 @@ describe( 'TreeWalker', () => {
 			];
 		} );
 
-		it( 'should provide iterator interface with default FORWARD direction', () => {
+		it( 'should provide iterator interface with default forward direction', () => {
 			let iterator = new TreeWalker( { startPosition: rootBeginning } );
 			let i = 0;
 
@@ -161,8 +161,8 @@ describe( 'TreeWalker', () => {
 			expect( i ).to.equal( expected.length );
 		} );
 
-		it( 'should provide iterator interface with FORWARD direction', () => {
-			let iterator = new TreeWalker( { startPosition: rootBeginning, direction: 'FORWARD' } );
+		it( 'should provide iterator interface with forward direction', () => {
+			let iterator = new TreeWalker( { startPosition: rootBeginning, direction: 'forward' } );
 			let i = 0;
 
 			for ( let value of iterator ) {
@@ -172,12 +172,12 @@ describe( 'TreeWalker', () => {
 			expect( i ).to.equal( expected.length );
 		} );
 
-		it( 'should provide iterator interface which BACKWARD direction', () => {
-			let iterator = new TreeWalker( { startPosition: rootEnding, direction: 'BACKWARD' } );
+		it( 'should provide iterator interface which backward direction', () => {
+			let iterator = new TreeWalker( { startPosition: rootEnding, direction: 'backward' } );
 			let i = expected.length;
 
 			for ( let value of iterator ) {
-				expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+				expectValue( value, expected[ --i ], { direction: 'backward' } );
 			}
 
 			expect( i ).to.equal( 0 );
@@ -210,11 +210,11 @@ describe( 'TreeWalker', () => {
 				}
 			];
 
-			let iterator = new TreeWalker( { startPosition: new Position( root, 1 ), direction: 'BACKWARD' } );
+			let iterator = new TreeWalker( { startPosition: new Position( root, 1 ), direction: 'backward' } );
 			let i = expected.length;
 
 			for ( let value of iterator ) {
-				expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+				expectValue( value, expected[ --i ], { direction: 'backward' } );
 			}
 
 			expect( i ).to.equal( 0 );
@@ -286,11 +286,11 @@ describe( 'TreeWalker', () => {
 			} );
 
 			it( 'should iterating over the range going backward', () => {
-				let iterator = new TreeWalker( { boundaries: range, direction: 'BACKWARD' } );
+				let iterator = new TreeWalker( { boundaries: range, direction: 'backward' } );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -351,13 +351,13 @@ describe( 'TreeWalker', () => {
 			it( 'should return part of the text going backward', () => {
 				let iterator = new TreeWalker( {
 						boundaries: range,
-						direction: 'BACKWARD'
+						direction: 'backward'
 					}
 				);
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -419,13 +419,13 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					boundaries: range,
 					startPosition: range.end,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -463,13 +463,13 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					boundaries: range,
 					startPosition: range.end,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -541,12 +541,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					boundaries: range,
 					startPosition: new Position( paragraph, 2 ),
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -662,12 +662,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					startPosition: rootEnding,
 					singleCharacters: true,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -741,12 +741,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					boundaries: range,
 					singleCharacters: true,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -786,11 +786,11 @@ describe( 'TreeWalker', () => {
 		} );
 
 		it( 'should not enter elements going backward', () => {
-			let iterator = new TreeWalker( { startPosition: rootEnding, shallow: true, direction: 'BACKWARD' } );
+			let iterator = new TreeWalker( { startPosition: rootEnding, shallow: true, direction: 'backward' } );
 			let i = expected.length;
 
 			for ( let value of iterator ) {
-				expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+				expectValue( value, expected[ --i ], { direction: 'backward' } );
 			}
 
 			expect( i ).to.equal( 0 );
@@ -863,12 +863,12 @@ describe( 'TreeWalker', () => {
 				let iterator = new TreeWalker( {
 					startPosition: rootEnding,
 					ignoreElementEnd: true,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -963,12 +963,12 @@ describe( 'TreeWalker', () => {
 					startPosition: rootEnding,
 					singleCharacters: true,
 					ignoreElementEnd: true,
-					direction: 'BACKWARD'
+					direction: 'backward'
 				} );
 				let i = expected.length;
 
 				for ( let value of iterator ) {
-					expectValue( value, expected[ --i ], { direction: 'BACKWARD' } );
+					expectValue( value, expected[ --i ], { direction: 'backward' } );
 				}
 
 				expect( i ).to.equal( 0 );
@@ -980,7 +980,7 @@ describe( 'TreeWalker', () => {
 function expectValue( value, expected, options = {} ) {
 	let expectedPreviousPosition, expectedNextPosition;
 
-	if ( options.direction == 'BACKWARD' ) {
+	if ( options.direction == 'backward' ) {
 		expectedNextPosition = expected.previousPosition;
 		expectedPreviousPosition = expected.nextPosition;
 	} else {