8
0
Просмотр исходного кода

Merge pull request #530 from ckeditor/t/ckeditor5/211

Changed const to lower case.
Szymon Cofalik 9 лет назад
Родитель
Сommit
b14bc85ce2
26 измененных файлов с 458 добавлено и 458 удалено
  1. 10 10
      packages/ckeditor5-engine/src/model/composer/modifyselection.js
  2. 9 9
      packages/ckeditor5-engine/src/model/delta/basic-transformations.js
  3. 1 1
      packages/ckeditor5-engine/src/model/element.js
  4. 1 1
      packages/ckeditor5-engine/src/model/liveselection.js
  5. 1 1
      packages/ckeditor5-engine/src/model/operation/moveoperation.js
  6. 1 1
      packages/ckeditor5-engine/src/model/operation/transform.js
  7. 27 27
      packages/ckeditor5-engine/src/model/position.js
  8. 3 3
      packages/ckeditor5-engine/src/model/range.js
  9. 5 5
      packages/ckeditor5-engine/src/model/schema.js
  10. 4 4
      packages/ckeditor5-engine/src/model/selection.js
  11. 35 35
      packages/ckeditor5-engine/src/model/treewalker.js
  12. 12 12
      packages/ckeditor5-engine/src/view/position.js
  13. 4 4
      packages/ckeditor5-engine/src/view/renderer.js
  14. 37 37
      packages/ckeditor5-engine/src/view/treewalker.js
  15. 3 3
      packages/ckeditor5-engine/tests/_utils-tests/model.js
  16. 5 5
      packages/ckeditor5-engine/tests/_utils/model.js
  17. 1 1
      packages/ckeditor5-engine/tests/model/composer/composer.js
  18. 14 14
      packages/ckeditor5-engine/tests/model/composer/modifyselection.js
  19. 3 3
      packages/ckeditor5-engine/tests/model/liveselection.js
  20. 14 14
      packages/ckeditor5-engine/tests/model/position.js
  21. 19 19
      packages/ckeditor5-engine/tests/model/schema/schemaitem.js
  22. 24 24
      packages/ckeditor5-engine/tests/model/selection.js
  23. 100 100
      packages/ckeditor5-engine/tests/model/treewalker.js
  24. 1 1
      packages/ckeditor5-engine/tests/tickets/475/475.js
  25. 8 8
      packages/ckeditor5-engine/tests/view/position.js
  26. 116 116
      packages/ckeditor5-engine/tests/view/treewalker.js

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

@@ -13,22 +13,22 @@ import Range from '../range.js';
  * Modifies the selection. Currently the supported modifications are:
  *
  * * Extending. The selection focus is moved in the specified `options.direction` with a step specified in `options.unit`
- * (defaults to `'CHARACTER'`, other values are not not yet supported).
+ * (defaults to `'character'`, other values are not not yet supported).
  * Note: if you extend a forward selection in a backward direction you will in fact shrink it.
  *
  * @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();
@@ -41,15 +41,15 @@ export default function modifySelection( selection, options = {} ) {
 	let value = next.value;
 
 	// 2. Consume next character.
-	if ( value.type == 'CHARACTER' ) {
+	if ( value.type == 'character' ) {
 		selection.setFocus( value.nextPosition );
 
 		return;
 	}
 
 	// 3. We're entering an element, so let's consume it fully.
-	if ( value.type == ( isForward ? 'ELEMENT_START' : 'ELEMENT_END' ) ) {
-		selection.setFocus( value.item, isForward ? 'AFTER' : 'BEFORE' );
+	if ( value.type == ( isForward ? 'elementStart' : 'elementEnd' ) ) {
+		selection.setFocus( value.item, isForward ? 'after' : 'before' );
 
 		return;
 	}
@@ -67,18 +67,18 @@ export default function modifySelection( selection, options = {} ) {
 
 	// 4.2. Character found after element end. Not really a valid case in our data model, but let's
 	// do something sensible and put the selection focus before that character.
-	if ( value.type == 'CHARACTER' ) {
+	if ( value.type == 'character' ) {
 		selection.setFocus( value.previousPosition );
 	}
 	// 4.3. OK, we're entering a new element. So let's place there the focus.
 	else {
-		selection.setFocus( value.item, isForward ? 0 : 'END' );
+		selection.setFocus( value.item, isForward ? 0 : 'end' );
 	}
 }
 
 function getSearchRange( start, isForward ) {
 	const root = start.root;
-	const searchEnd = Position.createAt( root, isForward ? 'END' : 0 );
+	const searchEnd = Position.createAt( root, isForward ? 'end' : 0 );
 
 	if ( isForward ) {
 		return new Range( start, searchEnd );

+ 9 - 9
packages/ckeditor5-engine/src/model/delta/basic-transformations.js

@@ -64,7 +64,7 @@ addTransformationCase( MoveDelta, MergeDelta, ( a, b, isStrong ) => {
 
 	const operateInSameParent =
 		a.sourcePosition.root == b.position.root &&
-		compareArrays( a.sourcePosition.getParentPath(), b.position.getParentPath() ) === 'SAME';
+		compareArrays( a.sourcePosition.getParentPath(), b.position.getParentPath() ) === 'same';
 
 	const mergeInsideMoveRange = a.sourcePosition.offset <= b.position.offset && a.sourcePosition.offset + a.howMany > b.position.offset;
 
@@ -96,7 +96,7 @@ addTransformationCase( MergeDelta, MoveDelta, ( a, b, isStrong ) => {
 
 	const operateInSameParent =
 		a.position.root == b.sourcePosition.root &&
-		compareArrays( a.position.getParentPath(), b.sourcePosition.getParentPath() ) === 'SAME';
+		compareArrays( a.position.getParentPath(), b.sourcePosition.getParentPath() ) === 'same';
 
 	const mergeInsideMoveRange = b.sourcePosition.offset <= a.position.offset && b.sourcePosition.offset + b.howMany > a.position.offset;
 
@@ -113,7 +113,7 @@ addTransformationCase( SplitDelta, SplitDelta, ( a, b, isStrong ) => {
 	const pathB = b.position.getParentPath();
 
 	// The special case is for splits inside the same parent.
-	if ( compareArrays( pathA, pathB ) == 'SAME' ) {
+	if ( compareArrays( pathA, pathB ) == 'same' ) {
 		if ( a.position.offset == b.position.offset ) {
 			// We are applying split at the position where split already happened. Additional split is not needed.
 			return [ noDelta() ];
@@ -167,7 +167,7 @@ addTransformationCase( SplitDelta, SplitDelta, ( a, b, isStrong ) => {
 addTransformationCase( SplitDelta, UnwrapDelta, ( a, b, isStrong ) => {
 	// If incoming split delta tries to split a node that just got unwrapped, there is actually nothing to split,
 	// so we discard that delta.
-	if ( compareArrays( b.position.path, a.position.getParentPath() ) === 'SAME' ) {
+	if ( compareArrays( b.position.path, a.position.getParentPath() ) === 'same' ) {
 		return [ noDelta() ];
 	}
 
@@ -179,12 +179,12 @@ addTransformationCase( SplitDelta, WrapDelta, ( a, b, isStrong ) => {
 	// If split is applied at the position between wrapped nodes, we cancel the split as it's results may be unexpected and
 	// very weird. Even if we do some "magic" we don't know what really are users' expectations.
 
-	const operateInSameParent = compareArrays( a.position.getParentPath(), b.range.start.getParentPath() ) === 'SAME';
+	const operateInSameParent = compareArrays( a.position.getParentPath(), b.range.start.getParentPath() ) === 'same';
 	const splitInsideWrapRange = b.range.start.offset < a.position.offset && b.range.end.offset >= a.position.offset;
 
 	if ( operateInSameParent && splitInsideWrapRange ) {
 		return [ noDelta() ];
-	} else if ( compareArrays( a.position.getParentPath(), b.range.end.getShiftedBy( -1 ).path ) === 'SAME' ) {
+	} else if ( compareArrays( a.position.getParentPath(), b.range.end.getShiftedBy( -1 ).path ) === 'same' ) {
 		// Split position is directly inside the last node from wrap range.
 		// If that's the case, we manually change split delta so it will "target" inside the wrapping element.
 		// By doing so we will be inserting split node right to the original node which feels natural and is a good UX.
@@ -229,7 +229,7 @@ addTransformationCase( SplitDelta, WrapDelta, ( a, b, isStrong ) => {
 addTransformationCase( UnwrapDelta, SplitDelta, ( a, b, isStrong ) => {
 	// If incoming unwrap delta tries to unwrap node that got split we should unwrap the original node and the split copy.
 	// This can be achieved either by reverting split and applying unwrap to singular node, or creating additional unwrap delta.
-	if ( compareArrays( a.position.path, b.position.getParentPath() ) === 'SAME' ) {
+	if ( compareArrays( a.position.path, b.position.getParentPath() ) === 'same' ) {
 		const transformed = [
 			b.getReversed(),
 			a.clone()
@@ -266,7 +266,7 @@ addTransformationCase( WrapDelta, SplitDelta, ( a, b, isStrong ) => {
 	// If incoming wrap delta tries to wrap range that contains split position, we have to cancel the split and apply
 	// the wrap. Since split was already applied, we have to revert it.
 
-	const operateInSameParent = compareArrays( a.range.start.getParentPath(), b.position.getParentPath() ) === 'SAME';
+	const operateInSameParent = compareArrays( a.range.start.getParentPath(), b.position.getParentPath() ) === 'same';
 	const splitInsideWrapRange = a.range.start.offset < b.position.offset && a.range.end.offset >= b.position.offset;
 
 	if ( operateInSameParent && splitInsideWrapRange ) {
@@ -274,7 +274,7 @@ addTransformationCase( WrapDelta, SplitDelta, ( a, b, isStrong ) => {
 			b.getReversed(),
 			a.clone()
 		];
-	} else if ( compareArrays( b.position.getParentPath(), a.range.end.getShiftedBy( -1 ).path ) === 'SAME' ) {
+	} else if ( compareArrays( b.position.getParentPath(), a.range.end.getShiftedBy( -1 ).path ) === 'same' ) {
 		const delta = a.clone();
 
 		// Move wrapping element insert position one node further so it is after the split node insertion.

+ 1 - 1
packages/ckeditor5-engine/src/model/element.js

@@ -190,7 +190,7 @@ export default class Element extends Node {
 		let text = '';
 
 		for ( let value of Range.createFromElement( this ) ) {
-			if ( value.type == 'TEXT' ) {
+			if ( value.type == 'text' ) {
 				text += value.item.text;
 			}
 		}

+ 1 - 1
packages/ckeditor5-engine/src/model/liveselection.js

@@ -295,7 +295,7 @@ export default class LiveSelection extends Selection {
 			for ( let item of range ) {
 				// This is not an optimal solution because of https://github.com/ckeditor/ckeditor5-engine/issues/454.
 				// It can be done better by using `break;` instead of checking `attrs === null`.
-				if ( item.type == 'TEXT' && attrs === null ) {
+				if ( item.type == 'text' && attrs === null ) {
 					attrs = item.item.getAttributes();
 				}
 			}

+ 1 - 1
packages/ckeditor5-engine/src/model/operation/moveoperation.js

@@ -140,7 +140,7 @@ export default class MoveOperation extends Operation {
 				'operation-move-range-into-itself: Trying to move a range of nodes to the inside of that range.'
 			);
 		} else if ( this.sourcePosition.root == this.targetPosition.root ) {
-			if ( compareArrays( this.sourcePosition.getParentPath(), this.targetPosition.getParentPath() ) == 'PREFIX' ) {
+			if ( compareArrays( this.sourcePosition.getParentPath(), this.targetPosition.getParentPath() ) == 'prefix' ) {
 				let i = this.sourcePosition.path.length - 1;
 
 				if ( this.targetPosition.path[ i ] >= sourceOffset && this.targetPosition.path[ i ] < sourceOffset + this.howMany ) {

+ 1 - 1
packages/ckeditor5-engine/src/model/operation/transform.js

@@ -322,7 +322,7 @@ const ot = {
 			let aIsInside = rangeB.containsRange( rangeA ) &&
 				( rangeB.containsPosition( a.targetPosition ) || rangeB.start.isEqual( a.targetPosition ) || rangeB.end.isEqual( a.targetPosition ) );
 
-			if ( common !== null && ( aCompB === 'EXTENSION' || ( aCompB === 'SAME' && isStrong ) || aIsInside ) && !bTargetsToA ) {
+			if ( common !== null && ( aCompB === 'extension' || ( aCompB === 'same' && isStrong ) || aIsInside ) && !bTargetsToA ) {
 				// Here we do not need to worry that newTargetPosition is inside moved range, because that
 				// would mean that the MoveOperation targets into itself, and that is incorrect operation.
 				// Instead, we calculate the new position of that part of original range.

+ 27 - 27
packages/ckeditor5-engine/src/model/position.js

@@ -142,26 +142,26 @@ export default class Position {
 	 */
 	compareWith( otherPosition ) {
 		if ( this.root != otherPosition.root ) {
-			return 'DIFFERENT';
+			return 'different';
 		}
 
 		const result = compareArrays( this.path, otherPosition.path );
 
 		switch ( result ) {
-			case 'SAME':
-				return 'SAME';
+			case 'same':
+				return 'same';
 
-			case 'PREFIX':
-				return 'BEFORE';
+			case 'prefix':
+				return 'before';
 
-			case 'EXTENSION':
-				return 'AFTER';
+			case 'extension':
+				return 'after';
 
 			default:
 				if ( this.path[ result ] < otherPosition.path[ result ] ) {
-					return 'BEFORE';
+					return 'before';
 				} else {
-					return 'AFTER';
+					return 'after';
 				}
 		}
 	}
@@ -209,7 +209,7 @@ export default class Position {
 			return transformed;
 		}
 
-		if ( compareArrays( deletePosition.getParentPath(), this.getParentPath() ) == 'SAME' ) {
+		if ( compareArrays( deletePosition.getParentPath(), this.getParentPath() ) == 'same' ) {
 			// If nodes are removed from the node that is pointed by this position...
 			if ( deletePosition.offset < this.offset ) {
 				// And are removed from before an offset of that position...
@@ -221,7 +221,7 @@ export default class Position {
 					transformed.offset -= howMany;
 				}
 			}
-		} else if ( compareArrays( deletePosition.getParentPath(), this.getParentPath() ) == 'PREFIX' ) {
+		} else if ( compareArrays( deletePosition.getParentPath(), this.getParentPath() ) == 'prefix' ) {
 			// If nodes are removed from a node that is on a path to this position...
 			const i = deletePosition.path.length - 1;
 
@@ -260,14 +260,14 @@ export default class Position {
 			return transformed;
 		}
 
-		if ( compareArrays( insertPosition.getParentPath(), this.getParentPath() ) == 'SAME' ) {
+		if ( compareArrays( insertPosition.getParentPath(), this.getParentPath() ) == 'same' ) {
 			// If nodes are inserted in the node that is pointed by this position...
 			if ( insertPosition.offset < this.offset || ( insertPosition.offset == this.offset && insertBefore ) ) {
 				// And are inserted before an offset of that position...
 				// "Push" this positions offset.
 				transformed.offset += howMany;
 			}
-		} else if ( compareArrays( insertPosition.getParentPath(), this.getParentPath() ) == 'PREFIX' ) {
+		} else if ( compareArrays( insertPosition.getParentPath(), this.getParentPath() ) == 'prefix' ) {
 			// If nodes are inserted in a node that is on a path to this position...
 			const i = insertPosition.path.length - 1;
 
@@ -324,7 +324,7 @@ export default class Position {
 	 * @returns {Boolean} True if this position is after given position.
 	 */
 	isAfter( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'AFTER';
+		return this.compareWith( otherPosition ) == 'after';
 	}
 
 	/**
@@ -359,7 +359,7 @@ export default class Position {
 	 * @returns {Boolean} True if this position is before given position.
 	 */
 	isBefore( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'BEFORE';
+		return this.compareWith( otherPosition ) == 'before';
 	}
 
 	/**
@@ -369,7 +369,7 @@ export default class Position {
 	 * @returns {Boolean} True if positions are same.
 	 */
 	isEqual( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'SAME';
+		return this.compareWith( otherPosition ) == 'same';
 	}
 
 	/**
@@ -386,15 +386,15 @@ export default class Position {
 		let compare = this.compareWith( otherPosition );
 
 		switch ( compare ) {
-			case 'SAME':
+			case 'same':
 				return true;
 
-			case 'BEFORE':
+			case 'before':
 				left = Position.createFromPosition( this );
 				right = Position.createFromPosition( otherPosition );
 				break;
 
-			case 'AFTER':
+			case 'after':
 				left = Position.createFromPosition( otherPosition );
 				right = Position.createFromPosition( this );
 				break;
@@ -448,8 +448,8 @@ export default class Position {
 	 *
 	 * * a {@link engine.model.Position position},
 	 * * parent element and offset (offset defaults to `0`),
-	 * * parent element and `'END'` (sets selection at the end of that element),
-	 * * node and `'BEFORE'` or `'AFTER'` (sets selection before or after the given node).
+	 * * parent element and `'end'` (sets selection at the end of that element),
+	 * * node and `'before'` or `'after'` (sets selection before or after the given node).
 	 *
 	 * This method is a shortcut to other constructors such as:
 	 *
@@ -459,7 +459,7 @@ export default class Position {
 	 * * {@link engine.model.Position.createFromPosition}.
 	 *
 	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
-	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
+	 * @param {Number|'end'|'before'|'after'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
 	static createAt( nodeOrPosition, offset ) {
@@ -470,11 +470,11 @@ export default class Position {
 		} else {
 			node = nodeOrPosition;
 
-			if ( offset == 'END' ) {
+			if ( offset == 'end' ) {
 				offset = node.getChildCount();
-			} else if ( offset == 'BEFORE' ) {
+			} else if ( offset == 'before' ) {
 				return this.createBefore( node );
-			} else if ( offset == 'AFTER' ) {
+			} else if ( offset == 'after' ) {
 				return this.createAfter( node );
 			} else if ( !offset ) {
 				offset = 0;
@@ -641,8 +641,8 @@ export default class Position {
 }
 
 /**
- * A flag indicating whether this position is `'BEFORE'` or `'AFTER'` or `'SAME'` as given position.
- * If positions are in different roots `'DIFFERENT'` flag is returned.
+ * A flag indicating whether this position is `'before'` or `'after'` or `'same'` as given position.
+ * If positions are in different roots `'different'` flag is returned.
  *
  * @typedef {String} engine.model.PositionRelation
  */

+ 3 - 3
packages/ckeditor5-engine/src/model/range.js

@@ -48,12 +48,12 @@ export default class Range {
 	 * range.
 	 *
 	 * **Note:** iterator will not return a parent node of start position. This is in contrary to
-	 * {@link engine.model.TreeWalker} which will return that node with `'ELEMENT_END'` type. Iterator also
+	 * {@link engine.model.TreeWalker} which will return that node with `'elementEnd'` type. Iterator also
 	 * returns each {@link engine.model.Element} once, while simply used {@link engine.model.TreeWalker} might
-	 * return it twice: for `'ELEMENT_START'` and `'ELEMENT_END'`.
+	 * return it twice: for `'elementStart'` and `'elementEnd'`.
 	 *
 	 * **Note:** because iterator does not return {@link engine.model.TreeWalkerValue values} with the type of
-	 * `'ELEMENT_END'`, you can use {@link engine.model.TreeWalkerValue.previousPosition} as a position before the
+	 * `'elementEnd'`, you can use {@link engine.model.TreeWalkerValue.previousPosition} as a position before the
 	 * item.
 	 *
 	 * @see engine.model.TreeWalker

+ 5 - 5
packages/ckeditor5-engine/src/model/schema.js

@@ -115,12 +115,12 @@ export class SchemaItem {
 	 * Returns all paths of given type that were previously registered in the item.
 	 *
 	 * @private
-	 * @param {String} type Paths' type. Possible values are `ALLOW` or `DISALLOW`.
+	 * @param {String} type Paths' type. Possible values are `allow` or `disallow`.
 	 * @param {String} [attribute] If set, only paths registered for given attribute will be returned.
 	 * @returns {Array} Paths registered in the item.
 	 */
 	_getPaths( type, attribute ) {
-		const source = type === 'ALLOW' ? this._allowed : this._disallowed;
+		const source = type === 'allow' ? this._allowed : this._disallowed;
 		const paths = [];
 
 		for ( let item of source ) {
@@ -165,7 +165,7 @@ export class SchemaItem {
 	 * Checks whether this item has any registered path of given type that matches provided path.
 	 *
 	 * @protected
-	 * @param {String} type Paths' type. Possible values are `ALLOW` or `DISALLOW`.
+	 * @param {String} type Paths' type. Possible values are `allow` or `disallow`.
 	 * @param {Array.<String>} checkPath Path to check.
 	 * @param {String} [attribute] If set, only paths registered for given attribute will be checked.
 	 * @returns {Boolean} `true` if item has any registered matching path, `false` otherwise.
@@ -384,7 +384,7 @@ export default class Schema {
 		// If there is matching disallow path, this query is not valid with schema.
 		for ( let attribute of query.attributes ) {
 			for ( let schemaItem of schemaItems ) {
-				if ( schemaItem._hasMatchingPath( 'DISALLOW', path, attribute ) ) {
+				if ( schemaItem._hasMatchingPath( 'disallow', path, attribute ) ) {
 					return false;
 				}
 			}
@@ -400,7 +400,7 @@ export default class Schema {
 			let matched = false;
 
 			for ( let schemaItem of schemaItems ) {
-				if ( schemaItem._hasMatchingPath( 'ALLOW', path, attribute ) ) {
+				if ( schemaItem._hasMatchingPath( 'allow', path, attribute ) ) {
 					matched = true;
 					break;
 				}

+ 4 - 4
packages/ckeditor5-engine/src/model/selection.js

@@ -306,7 +306,7 @@ export default class Selection {
 	 *
 	 * @fires engine.model.Selection#change:range
 	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
-	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
+	 * @param {Number|'end'|'before'|'after'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
 	collapse( nodeOrPosition, offset ) {
@@ -323,7 +323,7 @@ export default class Selection {
 	 *
 	 * @fires engine.model.Selection#change:range
 	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
-	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
+	 * @param {Number|'end'|'before'|'after'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
 	setFocus( nodeOrPosition, offset ) {
@@ -338,7 +338,7 @@ export default class Selection {
 
 		const newFocus = Position.createAt( nodeOrPosition, offset );
 
-		if ( newFocus.compareWith( this.focus ) == 'SAME' ) {
+		if ( newFocus.compareWith( this.focus ) == 'same' ) {
 			return;
 		}
 
@@ -348,7 +348,7 @@ export default class Selection {
 			this._popRange();
 		}
 
-		if ( newFocus.compareWith( anchor ) == 'BEFORE' ) {
+		if ( newFocus.compareWith( anchor ) == 'before' ) {
 			this.addRange( new Range( newFocus, anchor ), true );
 		} else {
 			this.addRange( new Range( anchor, newFocus ) );

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

@@ -22,18 +22,18 @@ 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
 	 * should be returned one by one as multiple {@link engine.model.CharacterProxy} (`true`) objects or as one
 	 * {@link engine.model.TextProxy} (`false`).
 	 * @param {Boolean} [options.shallow=false] Flag indicating whether iterator should enter elements or not. If the
-	 * iterator is shallow child nodes of any iterated node will not be returned along with `ELEMENT_END` tag.
-	 * @param {Boolean} [options.ignoreElementEnd=false] Flag indicating whether iterator should ignore `ELEMENT_END`
+	 * iterator is shallow child nodes of any iterated node will not be returned along with `elementEnd` tag.
+	 * @param {Boolean} [options.ignoreElementEnd=false] Flag indicating whether iterator should ignore `elementEnd`
 	 * tags. If the option is true walker will not return a parent node of start position. If this option is `true`
 	 * each {@link engine.model.Element} will be returned once, while if the option is `false` they might be returned
-	 * twice: for `'ELEMENT_START'` and `'ELEMENT_END'`.
+	 * twice: for `'elementStart'` and `'elementEnd'`.
 	 */
 	constructor( options = {} ) {
 		if ( !options.boundaries && !options.startPosition ) {
@@ -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' ] );
 		}
 
 		/**
@@ -101,7 +101,7 @@ export default class TreeWalker {
 
 		/**
 		 * Flag indicating whether iterator should enter elements or not. If the iterator is shallow child nodes of any
-		 * iterated node will not be returned along with `ELEMENT_END` tag.
+		 * iterated node will not be returned along with `elementEnd` tag.
 		 *
 		 * @readonly
 		 * @member {Boolean} engine.model.TreeWalker#shallow
@@ -109,10 +109,10 @@ export default class TreeWalker {
 		this.shallow = !!options.shallow;
 
 		/**
-		 * Flag indicating whether iterator should ignore `ELEMENT_END` tags. If the option is true walker will not
+		 * Flag indicating whether iterator should ignore `elementEnd` tags. If the option is true walker will not
 		 * return a parent node of the start position. If this option is `true` each {@link engine.model.Element} will
 		 * be returned once, while if the option is `false` they might be returned twice:
-		 * for `'ELEMENT_START'` and `'ELEMENT_END'`.
+		 * for `'elementStart'` and `'elementEnd'`.
 		 *
 		 * @readonly
 		 * @member {Boolean} engine.model.TreeWalker#ignoreElementEnd
@@ -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();
@@ -201,13 +201,13 @@ export default class TreeWalker {
 
 			this.position = position;
 
-			return formatReturnValue( 'ELEMENT_START', node, previousPosition, position, 1 );
+			return formatReturnValue( 'elementStart', node, previousPosition, position, 1 );
 		} else if ( node instanceof CharacterProxy ) {
 			if ( this.singleCharacters ) {
 				position.offset++;
 				this.position = position;
 
-				return formatReturnValue( 'CHARACTER', node, previousPosition, position, 1 );
+				return formatReturnValue( 'character', node, previousPosition, position, 1 );
 			} else {
 				let charactersCount = node._nodeListText.text.length - node._index;
 				let offset = position.offset + charactersCount;
@@ -222,7 +222,7 @@ export default class TreeWalker {
 				position.offset = offset;
 				this.position = position;
 
-				return formatReturnValue( 'TEXT', textProxy, previousPosition, position, charactersCount );
+				return formatReturnValue( 'text', textProxy, previousPosition, position, charactersCount );
 			}
 		} else {
 			// `node` is not set, we reached the end of current `parent`.
@@ -234,7 +234,7 @@ export default class TreeWalker {
 			if ( this.ignoreElementEnd ) {
 				return this._next();
 			} else {
-				return formatReturnValue( 'ELEMENT_END', parent, previousPosition, position );
+				return formatReturnValue( 'elementEnd', parent, previousPosition, position );
 			}
 		}
 	}
@@ -276,19 +276,19 @@ export default class TreeWalker {
 				if ( this.ignoreElementEnd ) {
 					return this._previous();
 				} else {
-					return formatReturnValue( 'ELEMENT_END', node, previousPosition, position );
+					return formatReturnValue( 'elementEnd', node, previousPosition, position );
 				}
 			} else {
 				this.position = position;
 
-				return formatReturnValue( 'ELEMENT_START', node, previousPosition, position, 1 );
+				return formatReturnValue( 'elementStart', node, previousPosition, position, 1 );
 			}
 		} else if ( node instanceof CharacterProxy ) {
 			if ( this.singleCharacters ) {
 				position.offset--;
 				this.position = position;
 
-				return formatReturnValue( 'CHARACTER', node, previousPosition, position, 1 );
+				return formatReturnValue( 'character', node, previousPosition, position, 1 );
 			} else {
 				let charactersCount = node._index + 1;
 				let offset = position.offset - charactersCount;
@@ -303,7 +303,7 @@ export default class TreeWalker {
 				position.offset = offset;
 				this.position = position;
 
-				return formatReturnValue( 'TEXT', textFragment, previousPosition, position, charactersCount );
+				return formatReturnValue( 'text', textFragment, previousPosition, position, charactersCount );
 			}
 		} else {
 			// `node` is not set, we reached the beginning of current `parent`.
@@ -311,7 +311,7 @@ export default class TreeWalker {
 			this.position = position;
 			this._visitedParent = parent.parent;
 
-			return formatReturnValue( 'ELEMENT_START', parent, previousPosition, position, 1 );
+			return formatReturnValue( 'elementStart', parent, previousPosition, position, 1 );
 		}
 	}
 }
@@ -331,8 +331,8 @@ function formatReturnValue( type, item, previousPosition, nextPosition, length )
 
 /**
  * Type of the step made by {@link engine.model.TreeWalker}.
- * Possible values: `'ELEMENT_START'` if walker is at the beginning of a node, `'ELEMENT_END'` if walker is at the end of node,
- * `'CHARACTER'` if walker traversed over a character, or `'TEXT'` if walker traversed over multiple characters (available in
+ * Possible values: `'elementStart'` if walker is at the beginning of a node, `'elementEnd'` if walker is at the end of node,
+ * `'character'` if walker traversed over a character, or `'text'` if walker traversed over multiple characters (available in
  * character merging mode, see {@link engine.model.TreeWalker#constructor}).
  *
  * @typedef {String} engine.model.TreeWalkerValueType
@@ -345,24 +345,24 @@ function formatReturnValue( type, item, previousPosition, nextPosition, length )
  * @property {engine.model.TreeWalkerValueType} type
  * @property {engine.model.Item} item Item between old and new positions of {@link engine.model.TreeWalker}.
  * @property {engine.model.Position} previousPosition Previous position of the iterator.
- * * Forward iteration: For `'ELEMENT_END'` it is the last position inside the element. For all other types it is the
+ * * Forward iteration: For `'elementEnd'` it is the last position inside the element. For all other types it is the
  * position before the item. Note that it is more efficient to use this position then calculate the position before
  * the node using {@link engine.model.Position.createBefore}. It is also more efficient to get the
  * position after node by shifting `previousPosition` by `length`, using {@link engine.model.Position#getShiftedBy},
  * then calculate the position using {@link engine.model.Position.createAfter}.
- * * Backward iteration: For `'ELEMENT_START'` it is the first position inside the element. For all other types it is
+ * * Backward iteration: For `'elementStart'` it is the first position inside the element. For all other types it is
  * the position after item.
  * @property {engine.model.Position} nextPosition Next position of the iterator.
- * * Forward iteration: For `'ELEMENT_START'` it is the first position inside the element. For all other types it is
+ * * Forward iteration: For `'elementStart'` it is the first position inside the element. For all other types it is
  * the position after the item.
- * * Backward iteration: For `'ELEMENT_END'` it is last position inside element. For all other types it is the position
+ * * Backward iteration: For `'elementEnd'` it is last position inside element. For all other types it is the position
  * before the item.
- * @property {Number} [length] Length of the item. For `'ELEMENT_START'` and `'CHARACTER'` it is 1. For `'TEXT'` it is
- * the length of the text. For `'ELEMENT_END'` it is undefined.
+ * @property {Number} [length] Length of the item. For `'elementStart'` and `'character'` it is 1. For `'text'` it is
+ * the length of the text. For `'elementEnd'` it is undefined.
  */
 
 /**
  * Tree walking directions.
  *
- * @typedef {'FORWARD'|'BACKWARD'} engine.view.TreeWalkerDirection
+ * @typedef {'forward'|'backward'} engine.view.TreeWalkerDirection
  */

+ 12 - 12
packages/ckeditor5-engine/src/view/position.js

@@ -106,7 +106,7 @@ export default class Position {
 	 * @returns {Boolean} Returns `true` if this position is before given position.
 	 */
 	isBefore( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'BEFORE';
+		return this.compareWith( otherPosition ) == 'before';
 	}
 
 	/**
@@ -120,7 +120,7 @@ export default class Position {
 	 * @returns {Boolean} Returns `true` if this position is after given position.
 	 */
 	isAfter( otherPosition ) {
-		return this.compareWith( otherPosition ) == 'AFTER';
+		return this.compareWith( otherPosition ) == 'after';
 	}
 
 	/**
@@ -132,12 +132,12 @@ export default class Position {
 	 */
 	compareWith( otherPosition ) {
 		if ( this.isEqual( otherPosition ) ) {
-			return 'SAME';
+			return 'same';
 		}
 
 		// If positions have same parent.
 		if ( this.parent === otherPosition.parent ) {
-			return this.offset - otherPosition.offset < 0 ? 'BEFORE' : 'AFTER';
+			return this.offset - otherPosition.offset < 0 ? 'before' : 'after';
 		}
 
 		// Get path from root to position's parent element.
@@ -152,13 +152,13 @@ export default class Position {
 		switch ( result ) {
 			case 0:
 				// No common ancestors found.
-				return 'DIFFERENT';
+				return 'different';
 
-			case 'PREFIX':
+			case 'prefix':
 				commonAncestorIndex = path.length - 1;
 				break;
 
-			case 'EXTENSION':
+			case 'extension':
 				commonAncestorIndex = otherPath.length - 1;
 				break;
 
@@ -175,17 +175,17 @@ export default class Position {
 		if ( commonAncestor === this.parent ) {
 			const index = this.offset - nextAncestor2.getIndex();
 
-			return index <= 0 ? 'BEFORE' : 'AFTER';
+			return index <= 0 ? 'before' : 'after';
 		} else if ( commonAncestor === otherPosition.parent ) {
 			const index = nextAncestor1.getIndex() - otherPosition.offset;
 
-			return index < 0 ? 'BEFORE' : 'AFTER';
+			return index < 0 ? 'before' : 'after';
 		}
 
 		const index = nextAncestor1.getIndex() - nextAncestor2.getIndex();
 
 		// Compare indexes of next ancestors inside common one.
-		return index < 0 ? 'BEFORE' : 'AFTER';
+		return index < 0 ? 'before' : 'after';
 	}
 
 	/**
@@ -269,8 +269,8 @@ export default class Position {
 }
 
 /**
- * A flag indicating whether this position is `'BEFORE'` or `'AFTER'` or `'SAME'` as given position.
- * If positions are in different roots `'DIFFERENT'` flag is returned.
+ * A flag indicating whether this position is `'before'` or `'after'` or `'same'` as given position.
+ * If positions are in different roots `'different'` flag is returned.
  *
  * @typedef {String} engine.view.PositionRelation
  */

+ 4 - 4
packages/ckeditor5-engine/src/view/renderer.js

@@ -89,7 +89,7 @@ export default class Renderer {
 
 		/**
 		 * Position of the inline {@link engine.view.filler filler}.
-		 * It should always be put BEFORE the text which contains filler.
+		 * It should always be put before the text which contains filler.
 		 *
 		 * @private
 		 * @member {engine.view.Position} engine.view.Renderer#_inlineFillerPosition
@@ -383,12 +383,12 @@ export default class Renderer {
 		let i = 0;
 
 		for ( let action of actions ) {
-			if ( action === 'INSERT' ) {
+			if ( action === 'insert' ) {
 				insertAt( domElement, i, expectedDomChildren[ i ] );
 				i++;
-			} else if ( action === 'DELETE' ) {
+			} else if ( action === 'delete' ) {
 				remove( actualDomChildren[ i ] );
-			} else { // 'EQUAL'
+			} else { // 'equal'
 				i++;
 			}
 		}

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

@@ -24,16 +24,16 @@ 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`).
 	 * @param {Boolean} [options.shallow=false] Flag indicating whether iterator should enter elements or not. If the
-	 * iterator is shallow child nodes of any iterated node will not be returned along with `ELEMENT_END` tag.
-	 * @param {Boolean} [options.ignoreElementEnd=false] Flag indicating whether iterator should ignore `ELEMENT_END`
+	 * iterator is shallow child nodes of any iterated node will not be returned along with `elementEnd` tag.
+	 * @param {Boolean} [options.ignoreElementEnd=false] Flag indicating whether iterator should ignore `elementEnd`
 	 * tags. If the option is true walker will not return a parent node of start position. If this option is `true`
 	 * each {@link engine.view.Element} will be returned once, while if the option is `false` they might be returned
-	 * twice: for `'ELEMENT_START'` and `'ELEMENT_END'`.
+	 * twice: for `'elementStart'` and `'elementEnd'`.
 	 */
 	constructor( options = {} ) {
 		if ( !options.boundaries && !options.startPosition ) {
@@ -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
@@ -97,7 +97,7 @@ export default class TreeWalker {
 
 		/**
 		 * Flag indicating whether iterator should enter elements or not. If the iterator is shallow child nodes of any
-		 * iterated node will not be returned along with `ELEMENT_END` tag.
+		 * iterated node will not be returned along with `elementEnd` tag.
 		 *
 		 * @readonly
 		 * @member {Boolean} engine.view.TreeWalker#shallow
@@ -105,9 +105,9 @@ export default class TreeWalker {
 		this.shallow = !!options.shallow;
 
 		/**
-		 * Flag indicating whether iterator should ignore `ELEMENT_END` tags. If set to `true`, walker will not
+		 * Flag indicating whether iterator should ignore `elementEnd` tags. If set to `true`, walker will not
 		 * return a parent node of the start position. Each {@link engine.view.Element} will be returned once.
-		 * When set to `false` each element might be returned twice: for `'ELEMENT_START'` and `'ELEMENT_END'`.
+		 * When set to `false` each element might be returned twice: for `'elementStart'` and `'elementEnd'`.
 		 *
 		 * @readonly
 		 * @member {Boolean} engine.view.TreeWalker#ignoreElementEnd
@@ -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();
@@ -194,7 +194,7 @@ export default class TreeWalker {
 
 			this.position = position;
 
-			return this._formatReturnValue( 'ELEMENT_START', node, previousPosition, position, 1 );
+			return this._formatReturnValue( 'elementStart', node, previousPosition, position, 1 );
 		} else if ( node instanceof Text ) {
 			if ( this.singleCharacters ) {
 				position = new Position( node, 0 );
@@ -217,7 +217,7 @@ export default class TreeWalker {
 
 				this.position = position;
 
-				return this._formatReturnValue( 'TEXT', item, previousPosition, position, charactersCount );
+				return this._formatReturnValue( 'text', item, previousPosition, position, charactersCount );
 			}
 		} else if ( typeof node == 'string' ) {
 			let textLength;
@@ -236,7 +236,7 @@ export default class TreeWalker {
 			position.offset += textLength;
 			this.position = position;
 
-			return this._formatReturnValue( 'TEXT', textProxy, previousPosition, position, textLength );
+			return this._formatReturnValue( 'text', textProxy, previousPosition, position, textLength );
 		} else {
 			// `node` is not set, we reached the end of current `parent`.
 			position = Position.createAfter( parent );
@@ -245,7 +245,7 @@ export default class TreeWalker {
 			if ( this.ignoreElementEnd ) {
 				return this._next();
 			} else {
-				return this._formatReturnValue( 'ELEMENT_END', parent, previousPosition, position );
+				return this._formatReturnValue( 'elementEnd', parent, previousPosition, position );
 			}
 		}
 	}
@@ -291,13 +291,13 @@ export default class TreeWalker {
 				if ( this.ignoreElementEnd ) {
 					return this._previous();
 				} else {
-					return this._formatReturnValue( 'ELEMENT_END', node, previousPosition, position );
+					return this._formatReturnValue( 'elementEnd', node, previousPosition, position );
 				}
 			} else {
 				position.offset--;
 				this.position = position;
 
-				return this._formatReturnValue( 'ELEMENT_START', node, previousPosition, position, 1 );
+				return this._formatReturnValue( 'elementStart', node, previousPosition, position, 1 );
 			}
 		} else if ( node instanceof Text ) {
 			if ( this.singleCharacters ) {
@@ -323,7 +323,7 @@ export default class TreeWalker {
 
 				this.position = position;
 
-				return this._formatReturnValue( 'TEXT', item, previousPosition, position, charactersCount );
+				return this._formatReturnValue( 'text', item, previousPosition, position, charactersCount );
 			}
 		} else if ( typeof node == 'string' ) {
 			let textLength;
@@ -343,13 +343,13 @@ export default class TreeWalker {
 
 			this.position = position;
 
-			return this._formatReturnValue( 'TEXT', textProxy, previousPosition, position, textLength );
+			return this._formatReturnValue( 'text', textProxy, previousPosition, position, textLength );
 		} else {
 			// `node` is not set, we reached the beginning of current `parent`.
 			position = Position.createBefore( parent );
 			this.position = position;
 
-			return this._formatReturnValue( 'ELEMENT_START', parent, previousPosition, position, 1 );
+			return this._formatReturnValue( 'elementStart', parent, previousPosition, position, 1 );
 		}
 	}
 
@@ -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 );
@@ -408,9 +408,9 @@ export default class TreeWalker {
 
 /**
  * Type of the step made by {@link engine.view.TreeWalker}.
- * Possible values: `'ELEMENT_START'` if walker is at the beginning of a node, `'ELEMENT_END'` if walker is at the end
- * of node, or `'TEXT'` if walker traversed over single and multiple characters.
- * For {@link engine.view.Text} `ELEMENT_START` and `ELEMENT_END` is not returned.
+ * Possible values: `'elementStart'` if walker is at the beginning of a node, `'elementEnd'` if walker is at the end
+ * of node, or `'text'` if walker traversed over single and multiple characters.
+ * For {@link engine.view.Text} `elementStart` and `elementEnd` is not returned.
  *
  * @typedef {String} engine.view.TreeWalkerValueType
  */
@@ -422,26 +422,26 @@ export default class TreeWalker {
  * @property {engine.view.TreeWalkerValueType} type
  * @property {engine.view.Item} item Item between old and new positions of {@link engine.view.TreeWalker}.
  * @property {engine.view.Position} previousPosition Previous position of the iterator.
- * * Forward iteration: For `'ELEMENT_END'` it is the last position inside the element. For all other types it is the
+ * * Forward iteration: For `'elementEnd'` it is the last position inside the element. For all other types it is the
  * position before the item. Note that it is more efficient to use this position then calculate the position before
  * the node using {@link engine.view.Position.createBefore}.
- * * Backward iteration: For `'ELEMENT_START'` it is the first position inside the element. For all other types it is
+ * * Backward iteration: For `'elementStart'` it is the first position inside the element. For all other types it is
  * the position after item.
  * * If the position is at the beginning or at the end of the {@link engine.view.Text} it is always moved from the
  * inside of the Text to its parent just before or just after Text.
  * @property {engine.view.Position} nextPosition Next position of the iterator.
- * * Forward iteration: For `'ELEMENT_START'` it is the first position inside the element. For all other types it is
+ * * Forward iteration: For `'elementStart'` it is the first position inside the element. For all other types it is
  * the position after the item.
- * * Backward iteration: For `'ELEMENT_END'` it is last position inside element. For all other types it is the position
+ * * Backward iteration: For `'elementEnd'` it is last position inside element. For all other types it is the position
  * before the item.
  * * If the position is at the beginning or at the end of the {@link engine.view.Text} it is always moved from the
  * inside of the Text to its parent just before or just after Text.
- * @property {Number} [length] Length of the item. For `'ELEMENT_START'` it is 1. For `'TEXT'` it is
- * the length of the text. For `'ELEMENT_END'` it is undefined.
+ * @property {Number} [length] Length of the item. For `'elementStart'` it is 1. For `'text'` it is
+ * the length of the text. For `'elementEnd'` it is undefined.
  */
 
 /**
  * Tree walking directions.
  *
- * @typedef {'FORWARD'|'BACKWARD'} engine.view.TreeWalkerDirection
+ * @typedef {'forward'|'backward'} engine.view.TreeWalkerDirection
  */

+ 3 - 3
packages/ckeditor5-engine/tests/_utils-tests/model.js

@@ -198,7 +198,7 @@ describe( 'model test utils', () => {
 			} );
 
 			it( 'writes selection collapsed at the text left boundary', () => {
-				selection.collapse( elA, 'AFTER' );
+				selection.collapse( elA, 'after' );
 
 				expect( stringify( root, selection ) ).to.equal(
 					'<a></a><selection />foo<$text bold=true>bar</$text><b></b>'
@@ -206,7 +206,7 @@ describe( 'model test utils', () => {
 			} );
 
 			it( 'writes selection collapsed at the text right boundary', () => {
-				selection.collapse( elB, 'BEFORE' );
+				selection.collapse( elB, 'before' );
 
 				expect( stringify( root, selection ) ).to.equal(
 					'<a></a>foo<$text bold=true>bar</$text><selection bold=true /><b></b>'
@@ -214,7 +214,7 @@ describe( 'model test utils', () => {
 			} );
 
 			it( 'writes selection collapsed at the end of the root', () => {
-				selection.collapse( root, 'END' );
+				selection.collapse( root, 'end' );
 
 				// Needed due to https://github.com/ckeditor/ckeditor5-engine/issues/320.
 				selection.clearAttributes();

+ 5 - 5
packages/ckeditor5-engine/tests/_utils/model.js

@@ -195,7 +195,7 @@ export function parse( data, options = {} ) {
 
 		collapsedSelection( token ) {
 			withSelection = true;
-			selection.collapse( root, 'END' );
+			selection.collapse( root, 'end' );
 			selection.setAttributesTo( token.attributes );
 		},
 
@@ -256,7 +256,7 @@ function writeItem( walkerValue, selection, options ) {
 	const type = walkerValue.type;
 	const item = walkerValue.item;
 
-	if ( type == 'ELEMENT_START' ) {
+	if ( type == 'elementStart' ) {
 		let attrs = writeAttributes( item.getAttributes() );
 
 		if ( attrs ) {
@@ -266,7 +266,7 @@ function writeItem( walkerValue, selection, options ) {
 		return `<${ item.name }>`;
 	}
 
-	if ( type == 'ELEMENT_END' ) {
+	if ( type == 'elementEnd' ) {
 		return `</${ item.name }>`;
 	}
 
@@ -313,12 +313,12 @@ function writeSelection( currentPosition, selection ) {
 	const range = selection.getFirstRange();
 
 	// Handle end of the selection.
-	if ( !selection.isCollapsed && range.end.compareWith( currentPosition ) == 'SAME' ) {
+	if ( !selection.isCollapsed && range.end.compareWith( currentPosition ) == 'same' ) {
 		return '</selection>';
 	}
 
 	// Handle no match.
-	if ( range.start.compareWith( currentPosition ) != 'SAME' ) {
+	if ( range.start.compareWith( currentPosition ) != 'same' ) {
 		return '';
 	}
 

+ 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' }
 		);
 	} );
 

+ 3 - 3
packages/ckeditor5-engine/tests/model/liveselection.js

@@ -167,12 +167,12 @@ describe( 'LiveSelection', () => {
 	describe( 'setFocus', () => {
 		it( 'modifies default range', () => {
 			const startPos = selection.getFirstPosition();
-			const endPos = Position.createAt( root, 'END' );
+			const endPos = Position.createAt( root, 'end' );
 
 			selection.setFocus( endPos );
 
-			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( endPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( endPos ) ).to.equal( 'same' );
 		} );
 
 		it( 'detaches the range it replaces', () => {

+ 14 - 14
packages/ckeditor5-engine/tests/model/position.js

@@ -164,15 +164,15 @@ describe( 'position', () => {
 		} );
 
 		it( 'should create positions from node and flag', () => {
-			expect( Position.createAt( root, 'END' ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
+			expect( Position.createAt( root, 'end' ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
 
-			expect( Position.createAt( p, 'BEFORE' ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
-			expect( Position.createAt( a, 'BEFORE' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
+			expect( Position.createAt( p, 'before' ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
+			expect( Position.createAt( a, 'before' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
 
-			expect( Position.createAt( p, 'AFTER' ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
-			expect( Position.createAt( a, 'AFTER' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
+			expect( Position.createAt( p, 'after' ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
+			expect( Position.createAt( a, 'after' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
 
-			expect( Position.createAt( ul, 'END' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
+			expect( Position.createAt( ul, 'end' ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
 		} );
 	} );
 
@@ -462,32 +462,32 @@ describe( 'position', () => {
 	} );
 
 	describe( 'compareWith', () => {
-		it( 'should return SAME if positions are same', () => {
+		it( 'should return same if positions are same', () => {
 			const position = new Position( root, [ 1, 2, 3 ] );
 			const compared = new Position( root, [ 1, 2, 3 ] );
 
-			expect( position.compareWith( compared ) ).to.equal( 'SAME' );
+			expect( position.compareWith( compared ) ).to.equal( 'same' );
 		} );
 
-		it( 'should return BEFORE if the position is before compared one', () => {
+		it( 'should return before if the position is before compared one', () => {
 			const position = new Position( root, [ 1, 2, 3 ] );
 			const compared = new Position( root, [ 1, 3 ] );
 
-			expect( position.compareWith( compared ) ).to.equal( 'BEFORE' );
+			expect( position.compareWith( compared ) ).to.equal( 'before' );
 		} );
 
-		it( 'should return AFTER if the position is after compared one', () => {
+		it( 'should return after if the position is after compared one', () => {
 			const position = new Position( root, [ 1, 2, 3, 4 ] );
 			const compared = new Position( root, [ 1, 2, 3 ] );
 
-			expect( position.compareWith( compared ) ).to.equal( 'AFTER' );
+			expect( position.compareWith( compared ) ).to.equal( 'after' );
 		} );
 
-		it( 'should return DIFFERENT if positions are in different roots', () => {
+		it( 'should return different if positions are in different roots', () => {
 			const position = new Position( root, [ 1, 2, 3 ] );
 			const compared = new Position( otherRoot, [ 1, 2, 3 ] );
 
-			expect( position.compareWith( compared ) ).to.equal( 'DIFFERENT' );
+			expect( position.compareWith( compared ) ).to.equal( 'different' );
 		} );
 	} );
 

+ 19 - 19
packages/ckeditor5-engine/tests/model/schema/schemaitem.js

@@ -42,7 +42,7 @@ describe( 'allow', () => {
 		item.allow( path1 );
 		item.allow( path2 );
 
-		let paths = item._getPaths( 'ALLOW' );
+		let paths = item._getPaths( 'allow' );
 
 		expect( paths.length ).to.equal( 2 );
 
@@ -58,8 +58,8 @@ describe( 'allow', () => {
 		item.allow( [ 'div' ] );
 		item.allow( [ 'header' ], 'bold' );
 
-		let pathsWithNoAttribute = item._getPaths( 'ALLOW' );
-		let pathsWithBoldAttribute = item._getPaths( 'ALLOW', 'bold' );
+		let pathsWithNoAttribute = item._getPaths( 'allow' );
+		let pathsWithBoldAttribute = item._getPaths( 'allow', 'bold' );
 
 		expect( pathsWithNoAttribute.length ).to.equal( 1 );
 		expect( pathsWithNoAttribute[ 0 ] ).to.deep.equal( [ 'div' ] );
@@ -78,7 +78,7 @@ describe( 'disallow', () => {
 		item.disallow( path1 );
 		item.disallow( path2 );
 
-		let paths = item._getPaths( 'DISALLOW' );
+		let paths = item._getPaths( 'disallow' );
 
 		expect( paths.length ).to.equal( 2 );
 
@@ -94,8 +94,8 @@ describe( 'disallow', () => {
 		item.disallow( [ 'div' ] );
 		item.disallow( [ 'header' ], 'bold' );
 
-		let pathsWithNoAttribute = item._getPaths( 'DISALLOW' );
-		let pathsWithBoldAttribute = item._getPaths( 'DISALLOW', 'bold' );
+		let pathsWithNoAttribute = item._getPaths( 'disallow' );
+		let pathsWithBoldAttribute = item._getPaths( 'disallow', 'bold' );
 
 		expect( pathsWithNoAttribute.length ).to.equal( 1 );
 		expect( pathsWithNoAttribute[ 0 ] ).to.deep.equal( [ 'div' ] );
@@ -111,25 +111,25 @@ describe( '_hasMatchingPath', () => {
 		item.allow( [ 'div' , 'header' ] );
 		item.allow( [ 'image' ] );
 
-		expect( item._hasMatchingPath( 'ALLOW', [ 'div', 'header' ] ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div', 'header' ] ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'div', 'header', 'span' ] ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'div', 'header' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div', 'header' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'div', 'header', 'span' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
 	} );
 
 	it( 'should return false if there are no allowed paths that match query path', () => {
 		item.allow( [ 'div', 'p' ] );
 
-		expect( item._hasMatchingPath( 'ALLOW', [ 'p' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'div' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'p', 'div' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'p' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'div' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'p', 'div' ] ) ).to.be.false;
 	} );
 
 	it( 'should return true if there is at least one disallowed path that matches query path', () => {
 		item.allow( [ 'div', 'header' ] );
 		item.disallow( [ 'p', 'header' ] );
 
-		expect( item._hasMatchingPath( 'DISALLOW', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'disallow', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
 	} );
 
 	it( 'should use only paths that are registered for given attribute', () => {
@@ -138,12 +138,12 @@ describe( '_hasMatchingPath', () => {
 		item.allow( [ 'header' ] );
 		item.disallow( [ 'header' ], 'bold' );
 
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div', 'p' ]  ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div' ], 'bold' ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div', 'p' ]  ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div' ], 'bold' ) ).to.be.true;
 
-		expect( item._hasMatchingPath( 'DISALLOW', [ 'html', 'div', 'header' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'DISALLOW', [ 'html', 'div', 'p', 'header', 'span' ], 'bold' ) ).to.be.true;
+		expect( item._hasMatchingPath( 'disallow', [ 'html', 'div', 'header' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'disallow', [ 'html', 'div', 'p', 'header', 'span' ], 'bold' ) ).to.be.true;
 	} );
 } );
 

+ 24 - 24
packages/ckeditor5-engine/tests/model/selection.js

@@ -206,7 +206,7 @@ describe( 'Selection', () => {
 		} );
 
 		it( 'sets selection at the end of the given parent', () => {
-			selection.collapse( root, 'END' );
+			selection.collapse( root, 'end' );
 
 			expect( selection ).to.have.property( 'isCollapsed', true );
 
@@ -216,7 +216,7 @@ describe( 'Selection', () => {
 		} );
 
 		it( 'sets selection before the specified element', () => {
-			selection.collapse( root.getChild( 1 ), 'BEFORE' );
+			selection.collapse( root.getChild( 1 ), 'before' );
 
 			expect( selection ).to.have.property( 'isCollapsed', true );
 
@@ -226,7 +226,7 @@ describe( 'Selection', () => {
 		} );
 
 		it( 'sets selection after the specified element', () => {
-			selection.collapse( root.getChild( 1 ), 'AFTER' );
+			selection.collapse( root.getChild( 1 ), 'after' );
 
 			expect( selection ).to.have.property( 'isCollapsed', true );
 
@@ -296,13 +296,13 @@ describe( 'Selection', () => {
 			const spy = sinon.spy();
 			selection.on( 'change:range', spy );
 
-			selection.setFocus( Position.createAt( root, 'END' ) );
+			selection.setFocus( Position.createAt( root, 'end' ) );
 
 			expect( spy.calledOnce ).to.be.true;
 		} );
 
 		it( 'throws if there are no ranges in selection', () => {
-			const endPos = Position.createAt( root, 'END' );
+			const endPos = Position.createAt( root, 'end' );
 
 			expect( () => {
 				selection.setFocus( endPos );
@@ -317,8 +317,8 @@ describe( 'Selection', () => {
 
 			selection.setFocus( endPos );
 
-			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( endPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( endPos ) ).to.equal( 'same' );
 		} );
 
 		it( 'makes existing collapsed selection a backward selection', () => {
@@ -329,8 +329,8 @@ describe( 'Selection', () => {
 
 			selection.setFocus( endPos );
 
-			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( endPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( endPos ) ).to.equal( 'same' );
 			expect( selection.isBackward ).to.be.true;
 		} );
 
@@ -343,8 +343,8 @@ describe( 'Selection', () => {
 
 			selection.setFocus( newEndPos );
 
-			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
 		} );
 
 		it( 'makes existing non-collapsed selection a backward selection', () => {
@@ -356,8 +356,8 @@ describe( 'Selection', () => {
 
 			selection.setFocus( newEndPos );
 
-			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
 			expect( selection.isBackward ).to.be.true;
 		} );
 
@@ -370,8 +370,8 @@ describe( 'Selection', () => {
 
 			selection.setFocus( newEndPos );
 
-			expect( selection.anchor.compareWith( endPos ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( endPos ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
 			expect( selection.isBackward ).to.be.false;
 		} );
 
@@ -384,8 +384,8 @@ describe( 'Selection', () => {
 
 			selection.setFocus( newEndPos );
 
-			expect( selection.anchor.compareWith( endPos ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( endPos ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
 			expect( selection.isBackward ).to.be.true;
 		} );
 
@@ -410,11 +410,11 @@ describe( 'Selection', () => {
 			const ranges = Array.from( selection.getRanges() );
 
 			expect( ranges ).to.have.lengthOf( 2 );
-			expect( ranges[ 0 ].start.compareWith( startPos1 ) ).to.equal( 'SAME' );
-			expect( ranges[ 0 ].end.compareWith( endPos1 ) ).to.equal( 'SAME' );
+			expect( ranges[ 0 ].start.compareWith( startPos1 ) ).to.equal( 'same' );
+			expect( ranges[ 0 ].end.compareWith( endPos1 ) ).to.equal( 'same' );
 
-			expect( selection.anchor.compareWith( startPos2 ) ).to.equal( 'SAME' );
-			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'SAME' );
+			expect( selection.anchor.compareWith( startPos2 ) ).to.equal( 'same' );
+			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
 			expect( selection.isBackward ).to.be.true;
 
 			expect( spy.calledOnce ).to.be.true;
@@ -428,7 +428,7 @@ describe( 'Selection', () => {
 
 			selection.setFocus( startPos );
 
-			expect( selection.focus.compareWith( startPos ) ).to.equal( 'SAME' );
+			expect( selection.focus.compareWith( startPos ) ).to.equal( 'same' );
 			expect( selection.isCollapsed ).to.be.true;
 		} );
 
@@ -440,10 +440,10 @@ describe( 'Selection', () => {
 
 			selection.addRange( new Range( startPos, endPos ) );
 
-			selection.setFocus( root, 'END' );
+			selection.setFocus( root, 'end' );
 
 			expect( spy.calledOnce ).to.be.true;
-			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'SAME' );
+			expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
 		} );
 	} );
 

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

@@ -66,7 +66,7 @@ describe( 'TreeWalker', () => {
 
 		it( 'should throw if walking direction is unknown', () => {
 			expect( () => {
-				new TreeWalker( { startPosition: rootBeginning, direction: 'UNKNOWN' } );
+				new TreeWalker( { startPosition: rootBeginning, direction: 'unknown' } );
 			} ).to.throw( CKEditorError, /^tree-walker-unknown-direction/ );
 		} );
 	} );
@@ -76,19 +76,19 @@ describe( 'TreeWalker', () => {
 
 		beforeEach( () => {
 			expected = [
-				{ type: 'ELEMENT_START', item: img1 },
-				{ type: 'ELEMENT_END', item: img1 },
-				{ type: 'ELEMENT_START', item: paragraph },
-				{ type: 'TEXT', text: 'ba', attrs: [ [ 'bold', true ] ] },
-				{ type: 'TEXT', text: 'r', attrs: [] },
-				{ type: 'ELEMENT_START', item: img2 },
-				{ type: 'ELEMENT_END', item: img2 },
-				{ type: 'TEXT', text: 'x', attrs: [] },
-				{ type: 'ELEMENT_END', item: paragraph }
+				{ type: 'elementStart', item: img1 },
+				{ type: 'elementEnd', item: img1 },
+				{ type: 'elementStart', item: paragraph },
+				{ type: 'text', text: 'ba', attrs: [ [ 'bold', true ] ] },
+				{ type: 'text', text: 'r', attrs: [] },
+				{ type: 'elementStart', item: img2 },
+				{ type: 'elementEnd', item: img2 },
+				{ type: 'text', text: 'x', attrs: [] },
+				{ type: 'elementEnd', item: paragraph }
 			];
 		} );
 
-		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 );
@@ -137,15 +137,15 @@ describe( 'TreeWalker', () => {
 
 		it( 'should start iterating at the startPosition witch is not a root bound, going backward', () => {
 			let expected = [
-				{ type: 'ELEMENT_START', item: img1 },
-				{ type: 'ELEMENT_END', item: img1 }
+				{ type: 'elementStart', item: img1 },
+				{ 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 );
@@ -158,11 +158,11 @@ describe( 'TreeWalker', () => {
 
 			before( () => {
 				expected = [
-					{ type: 'ELEMENT_START', item: paragraph },
-					{ type: 'TEXT', text: 'ba', attrs: [ [ 'bold', true ] ] },
-					{ type: 'TEXT', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 },
-					{ type: 'ELEMENT_END', item: img2 }
+					{ type: 'elementStart', item: paragraph },
+					{ type: 'text', text: 'ba', attrs: [ [ 'bold', true ] ] },
+					{ type: 'text', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 },
+					{ type: 'elementEnd', item: img2 }
 				];
 
 				range = new Range( new Position( root, [ 1 ] ), new Position( root, [ 1, 4 ] ) );
@@ -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 );
@@ -197,10 +197,10 @@ describe( 'TreeWalker', () => {
 
 			before( () => {
 				expected = [
-					{ type: 'TEXT', text: 'a', attrs: [ [ 'bold', true ] ] },
-					{ type: 'TEXT', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 },
-					{ type: 'ELEMENT_END', item: img2 }
+					{ type: 'text', text: 'a', attrs: [ [ 'bold', true ] ] },
+					{ type: 'text', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 },
+					{ type: 'elementEnd', item: img2 }
 				];
 
 				range = new Range( new Position( root, [ 1, 1 ] ), new Position( root, [ 1, 4 ] ) );
@@ -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 );
@@ -238,10 +238,10 @@ describe( 'TreeWalker', () => {
 
 			before( () => {
 				expected = [
-					{ type: 'ELEMENT_START', item: img1 },
-					{ type: 'ELEMENT_END', item: img1 },
-					{ type: 'ELEMENT_START', item: paragraph },
-					{ type: 'TEXT', text: 'b', attrs: [ [ 'bold', true ] ] }
+					{ type: 'elementStart', item: img1 },
+					{ type: 'elementEnd', item: img1 },
+					{ type: 'elementStart', item: paragraph },
+					{ type: 'text', text: 'b', attrs: [ [ 'bold', true ] ] }
 				];
 
 				range = new Range( rootBeginning, new Position( root, [ 1, 1 ] ) );
@@ -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 );
@@ -278,9 +278,9 @@ describe( 'TreeWalker', () => {
 		describe( 'custom start position', () => {
 			it( 'should iterating from the start position', () => {
 				let expected = [
-					{ type: 'TEXT', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 },
-					{ type: 'ELEMENT_END', item: img2 }
+					{ type: 'text', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 },
+					{ type: 'elementEnd', item: img2 }
 				];
 
 				let range = new Range( new Position( root, [ 1 ] ), new Position( root, [ 1, 4 ] ) );
@@ -301,9 +301,9 @@ describe( 'TreeWalker', () => {
 
 			it( 'should iterating from the start position going backward', () => {
 				let expected = [
-					{ type: 'TEXT', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 },
-					{ type: 'ELEMENT_END', item: img2 }
+					{ type: 'text', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 },
+					{ type: 'elementEnd', item: img2 }
 				];
 
 				let range = new Range( new Position( root, [ 1, 2 ] ), new Position( root, [ 1, 6 ] ) );
@@ -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 );
@@ -330,16 +330,16 @@ describe( 'TreeWalker', () => {
 
 			before( () => {
 				expected = [
-					{ type: 'ELEMENT_START', item: img1 },
-					{ type: 'ELEMENT_END', item: img1 },
-					{ type: 'ELEMENT_START', item: paragraph },
-					{ type: 'CHARACTER', text: 'b', attrs: [ [ 'bold', true ] ] },
-					{ type: 'CHARACTER', text: 'a', attrs: [ [ 'bold', true ] ] },
-					{ type: 'CHARACTER', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 },
-					{ type: 'ELEMENT_END', item: img2 },
-					{ type: 'CHARACTER', text: 'x', attrs: [] },
-					{ type: 'ELEMENT_END', item: paragraph }
+					{ type: 'elementStart', item: img1 },
+					{ type: 'elementEnd', item: img1 },
+					{ type: 'elementStart', item: paragraph },
+					{ type: 'character', text: 'b', attrs: [ [ 'bold', true ] ] },
+					{ type: 'character', text: 'a', attrs: [ [ 'bold', true ] ] },
+					{ type: 'character', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 },
+					{ type: 'elementEnd', item: img2 },
+					{ type: 'character', text: 'x', attrs: [] },
+					{ type: 'elementEnd', item: paragraph }
 				];
 			} );
 
@@ -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 );
@@ -376,10 +376,10 @@ describe( 'TreeWalker', () => {
 
 			before( () => {
 				expected = [
-					{ type: 'CHARACTER', text: 'b', attrs: [ [ 'bold', true ] ] },
-					{ type: 'CHARACTER', text: 'a', attrs: [ [ 'bold', true ] ] },
-					{ type: 'CHARACTER', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 }
+					{ type: 'character', text: 'b', attrs: [ [ 'bold', true ] ] },
+					{ type: 'character', text: 'a', attrs: [ [ 'bold', true ] ] },
+					{ type: 'character', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 }
 				];
 
 				start = new Position( root, [ 1, 0 ] ); // p, 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 );
@@ -417,13 +417,13 @@ describe( 'TreeWalker', () => {
 		} );
 	} );
 
-	describe( 'iterate omitting child nodes and ELEMENT_END `shallow`', () => {
+	describe( 'iterate omitting child nodes and elementEnd `shallow`', () => {
 		let expected;
 
 		before( () => {
 			expected = [
-				{ type: 'ELEMENT_START', item: img1 },
-				{ type: 'ELEMENT_START', item: paragraph }
+				{ type: 'elementStart', item: img1 },
+				{ type: 'elementStart', item: paragraph }
 			];
 		} );
 
@@ -440,33 +440,33 @@ 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 );
 		} );
 	} );
 
-	describe( 'iterate omitting ELEMENT_END `ignoreElementEnd`', () => {
+	describe( 'iterate omitting elementEnd `ignoreElementEnd`', () => {
 		describe( 'merged text', () => {
 			let expected;
 
 			before( () => {
 				expected = [
-					{ type: 'ELEMENT_START', item: img1 },
-					{ type: 'ELEMENT_START', item: paragraph },
-					{ type: 'TEXT', text: 'ba', attrs: [ [ 'bold', true ] ] },
-					{ type: 'TEXT', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 },
-					{ type: 'TEXT', text: 'x', attrs: [] }
+					{ type: 'elementStart', item: img1 },
+					{ type: 'elementStart', item: paragraph },
+					{ type: 'text', text: 'ba', attrs: [ [ 'bold', true ] ] },
+					{ type: 'text', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 },
+					{ type: 'text', text: 'x', attrs: [] }
 				];
 			} );
 
-			it( 'should iterate ignoring ELEMENT_END', () => {
+			it( 'should iterate ignoring elementEnd', () => {
 				let iterator = new TreeWalker( { startPosition: rootBeginning, ignoreElementEnd: true } );
 				let i = 0;
 
@@ -478,16 +478,16 @@ describe( 'TreeWalker', () => {
 				expect( i ).to.equal( expected.length );
 			} );
 
-			it( 'should iterate ignoring ELEMENT_END going backward', () => {
+			it( 'should iterate ignoring elementEnd going backward', () => {
 				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 );
@@ -499,17 +499,17 @@ describe( 'TreeWalker', () => {
 
 			before( () => {
 				expected = [
-					{ type: 'ELEMENT_START', item: img1 },
-					{ type: 'ELEMENT_START', item: paragraph },
-					{ type: 'CHARACTER', text: 'b', attrs: [ [ 'bold', true ] ] },
-					{ type: 'CHARACTER', text: 'a', attrs: [ [ 'bold', true ] ] },
-					{ type: 'CHARACTER', text: 'r', attrs: [] },
-					{ type: 'ELEMENT_START', item: img2 },
-					{ type: 'CHARACTER', text: 'x', attrs: [] }
+					{ type: 'elementStart', item: img1 },
+					{ type: 'elementStart', item: paragraph },
+					{ type: 'character', text: 'b', attrs: [ [ 'bold', true ] ] },
+					{ type: 'character', text: 'a', attrs: [ [ 'bold', true ] ] },
+					{ type: 'character', text: 'r', attrs: [] },
+					{ type: 'elementStart', item: img2 },
+					{ type: 'character', text: 'x', attrs: [] }
 				];
 			} );
 
-			it( 'should return single characters ignoring ELEMENT_END', () => {
+			it( 'should return single characters ignoring elementEnd', () => {
 				let iterator = new TreeWalker( {
 					startPosition: rootBeginning,
 					singleCharacters: true,
@@ -525,17 +525,17 @@ describe( 'TreeWalker', () => {
 				expect( i ).to.equal( expected.length );
 			} );
 
-			it( 'should return single characters ignoring ELEMENT_END going backward', () => {
+			it( 'should return single characters ignoring elementEnd going backward', () => {
 				let iterator = new 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 );
@@ -547,13 +547,13 @@ describe( 'TreeWalker', () => {
 function expectValue( value, expected, options ) {
 	expect( value.type ).to.equal( expected.type );
 
-	if ( value.type == 'TEXT' ) {
+	if ( value.type == 'text' ) {
 		expectText( value, expected, options );
-	} else if ( value.type == 'CHARACTER' ) {
+	} else if ( value.type == 'character' ) {
 		expectCharacter( value, expected, options );
-	} else if ( value.type == 'ELEMENT_START' ) {
+	} else if ( value.type == 'elementStart' ) {
 		expectStart( value, expected, options );
-	} else if ( value.type == 'ELEMENT_END' ) {
+	} else if ( value.type == 'elementEnd' ) {
 		expectEnd( value, expected, options );
 	}
 }
@@ -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 )
 				} );
 

+ 8 - 8
packages/ckeditor5-engine/tests/view/position.js

@@ -257,37 +257,37 @@ describe( 'Position', () => {
 	} );
 
 	describe( 'compareWith', () => {
-		it( 'should return SAME if positions are same', () => {
+		it( 'should return same if positions are same', () => {
 			const root = new Node();
 			const position = new Position( root, 0 );
 			const compared = new Position( root, 0 );
 
-			expect( position.compareWith( compared ) ).to.equal( 'SAME' );
+			expect( position.compareWith( compared ) ).to.equal( 'same' );
 		} );
 
-		it( 'should return BEFORE if the position is before compared one', () => {
+		it( 'should return before if the position is before compared one', () => {
 			const root = new Node();
 			const position = new Position( root, 0 );
 			const compared = new Position( root, 1 );
 
-			expect( position.compareWith( compared ) ).to.equal( 'BEFORE' );
+			expect( position.compareWith( compared ) ).to.equal( 'before' );
 		} );
 
-		it( 'should return AFTER if the position is after compared one', () => {
+		it( 'should return after if the position is after compared one', () => {
 			const root = new Node();
 			const position = new Position( root, 4 );
 			const compared = new Position( root, 1 );
 
-			expect( position.compareWith( compared ) ).to.equal( 'AFTER' );
+			expect( position.compareWith( compared ) ).to.equal( 'after' );
 		} );
 
-		it( 'should return DIFFERENT if positions are in different roots', () => {
+		it( 'should return different if positions are in different roots', () => {
 			const root1 = new Node();
 			const root2 = new Node();
 			const position = new Position( root1, 4 );
 			const compared = new Position( root2, 1 );
 
-			expect( position.compareWith( compared ) ).to.equal( 'DIFFERENT' );
+			expect( position.compareWith( compared ) ).to.equal( 'different' );
 		} );
 	} );
 

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

@@ -71,7 +71,7 @@ describe( 'TreeWalker', () => {
 
 		it( 'should throw if walking direction is unknown', () => {
 			expect( () => {
-				new TreeWalker( { startPosition: rootBeginning, direction: 'UNKNOWN' } );
+				new TreeWalker( { startPosition: rootBeginning, direction: 'unknown' } );
 			} ).to.throw( CKEditorError, /^tree-walker-unknown-direction/ );
 		} );
 	} );
@@ -82,67 +82,67 @@ describe( 'TreeWalker', () => {
 		beforeEach( () => {
 			expected = [
 				{
-					type: 'ELEMENT_START',
+					type: 'elementStart',
 					item: img1,
 					previousPosition: new Position( root, 0 ),
 					nextPosition: new Position( img1, 0 )
 				},
 				{
-					type: 'ELEMENT_END',
+					type: 'elementEnd',
 					item: img1,
 					previousPosition: new Position( img1, 0 ),
 					nextPosition: new Position( root, 1 )
 				},
 				{
-					type: 'ELEMENT_START',
+					type: 'elementStart',
 					item: paragraph,
 					previousPosition: new Position( root, 1 ),
 					nextPosition: new Position( paragraph, 0 )
 				},
 				{
-					type: 'ELEMENT_START',
+					type: 'elementStart',
 					item: bold,
 					previousPosition: new Position( paragraph, 0 ),
 					nextPosition: new Position( bold, 0 )
 				},
 				{
-					type: 'TEXT',
+					type: 'text',
 					text: 'abcd',
 					previousPosition: new Position( bold, 0 ),
 					nextPosition: new Position( bold, 1 )
 				},
 				{
-					type: 'ELEMENT_END',
+					type: 'elementEnd',
 					item: bold,
 					previousPosition: new Position( bold, 1 ),
 					nextPosition: new Position( paragraph, 1 )
 				},
 				{
-					type: 'TEXT',
+					type: 'text',
 					text: 'y',
 					previousPosition: new Position( paragraph, 1 ),
 					nextPosition: new Position( paragraph, 2 )
 				},
 				{
-					type: 'ELEMENT_START',
+					type: 'elementStart',
 					item: img2,
 					previousPosition: new Position( paragraph, 2 ),
 					nextPosition: new Position( img2, 0 )
 				},
 				{
-					type: 'ELEMENT_END',
+					type: 'elementEnd',
 					item: img2,
 					previousPosition: new Position( img2, 0 ),
 					nextPosition: new Position( paragraph, 3 )
 				},
 				{
-					type: 'TEXT',
+					type: 'text',
 					text: 'x',
 					previousPosition: new Position( paragraph, 3 ),
 					nextPosition: new Position( paragraph, 4 )
 				},
 				{
-					type: 'ELEMENT_END',
+					type: 'elementEnd',
 					item: paragraph,
 					previousPosition: new Position( paragraph, 4 ),
 					nextPosition: new Position( root, 2 )
@@ -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 );
@@ -197,24 +197,24 @@ describe( 'TreeWalker', () => {
 		it( 'should start iterating at the startPosition witch is not a root bound, going backward', () => {
 			let expected = [
 				{
-					type: 'ELEMENT_START',
+					type: 'elementStart',
 					item: img1,
 					previousPosition: new Position( root, 0 ),
 					nextPosition: new Position( img1, 0 )
 				},
 				{
-					type: 'ELEMENT_END',
+					type: 'elementEnd',
 					item: img1,
 					previousPosition: new Position( img1, 0 ),
 					nextPosition: new Position( root, 1 )
 				}
 			];
 
-			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 );
@@ -228,43 +228,43 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: paragraph,
 						previousPosition: new Position( root, 1 ),
 						nextPosition: new Position( paragraph, 0 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: bold,
 						previousPosition: new Position( paragraph, 0 ),
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'abcd',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: bold,
 						previousPosition: new Position( bold, 1 ),
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img2,
 						previousPosition: new Position( paragraph, 2 ),
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: img2,
 						previousPosition: new Position( img2, 0 ),
 						nextPosition: new Position( paragraph, 3 )
@@ -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 );
@@ -303,31 +303,31 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'bcd',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: bold,
 						previousPosition: new Position( bold, 1 ),
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img2,
 						previousPosition: new Position( paragraph, 2 ),
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: img2,
 						previousPosition: new Position( img2, 0 ),
 						nextPosition: new Position( paragraph, 3 )
@@ -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 );
@@ -370,31 +370,31 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img1,
 						previousPosition: new Position( root, 0 ),
 						nextPosition: new Position( img1, 0 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: img1,
 						previousPosition: new Position( img1, 0 ),
 						nextPosition: new Position( root, 1 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: paragraph,
 						previousPosition: new Position( root, 1 ),
 						nextPosition: new Position( paragraph, 0 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: bold,
 						previousPosition: new Position( paragraph, 0 ),
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'ab',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 2 )
@@ -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 );
@@ -438,7 +438,7 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'bc',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 3 )
@@ -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 );
@@ -480,19 +480,19 @@ describe( 'TreeWalker', () => {
 			it( 'should iterating from the start position', () => {
 				let expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img2,
 						previousPosition: new Position( paragraph, 2 ),
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: img2,
 						previousPosition: new Position( img2, 0 ),
 						nextPosition: new Position( paragraph, 3 )
@@ -517,19 +517,19 @@ describe( 'TreeWalker', () => {
 			it( 'should iterating from the start position going backward', () => {
 				let expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'bcd',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: bold,
 						previousPosition: new Position( bold, 1 ),
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
@@ -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 );
@@ -561,85 +561,85 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img1,
 						previousPosition: new Position( root, 0 ),
 						nextPosition: new Position( img1, 0 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: img1,
 						previousPosition: new Position( img1, 0 ),
 						nextPosition: new Position( root, 1 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: paragraph,
 						previousPosition: new Position( root, 1 ),
 						nextPosition: new Position( paragraph, 0 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: bold,
 						previousPosition: new Position( paragraph, 0 ),
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'a',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'b',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 2 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'c',
 						previousPosition: new Position( textAbcd, 2 ),
 						nextPosition: new Position( textAbcd, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'd',
 						previousPosition: new Position( textAbcd, 3 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: bold,
 						previousPosition: new Position( bold, 1 ),
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img2,
 						previousPosition: new Position( paragraph, 2 ),
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: img2,
 						previousPosition: new Position( img2, 0 ),
 						nextPosition: new Position( paragraph, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'x',
 						previousPosition: new Position( paragraph, 3 ),
 						nextPosition: new Position( paragraph, 4 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: paragraph,
 						previousPosition: new Position( paragraph, 4 ),
 						nextPosition: new Position( root, 2 )
@@ -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 );
@@ -680,43 +680,43 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'a',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'b',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 2 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'c',
 						previousPosition: new Position( textAbcd, 2 ),
 						nextPosition: new Position( textAbcd, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'd',
 						previousPosition: new Position( textAbcd, 3 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'ELEMENT_END',
+						type: 'elementEnd',
 						item: bold,
 						previousPosition: new Position( bold, 1 ),
 						nextPosition: new Position( paragraph, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img2,
 						previousPosition: new Position( paragraph, 2 ),
 						nextPosition: new Position( img2, 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 );
@@ -754,19 +754,19 @@ describe( 'TreeWalker', () => {
 		} );
 	} );
 
-	describe( 'iterate omitting child nodes and ELEMENT_END `shallow`', () => {
+	describe( 'iterate omitting child nodes and elementEnd `shallow`', () => {
 		let expected;
 
 		before( () => {
 			expected = [
 				{
-					type: 'ELEMENT_START',
+					type: 'elementStart',
 					item: img1,
 					previousPosition: new Position( root, 0 ),
 					nextPosition: new Position( root, 1 )
 				},
 				{
-					type: 'ELEMENT_START',
+					type: 'elementStart',
 					item: paragraph,
 					previousPosition: new Position( root, 1 ),
 					nextPosition: new Position( root, 2 )
@@ -786,61 +786,61 @@ 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 );
 		} );
 	} );
 
-	describe( 'iterate omitting ELEMENT_END `ignoreElementEnd`', () => {
+	describe( 'iterate omitting elementEnd `ignoreElementEnd`', () => {
 		describe( 'merged text', () => {
 			let expected;
 
 			before( () => {
 				expected = [
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img1,
 						previousPosition: new Position( root, 0 ),
 						nextPosition: new Position( img1, 0 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: paragraph,
 						previousPosition: new Position( root, 1 ),
 						nextPosition: new Position( paragraph, 0 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: bold,
 						previousPosition: new Position( paragraph, 0 ),
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'abcd',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img2,
 						previousPosition: new Position( paragraph, 2 ),
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'x',
 						previousPosition: new Position( paragraph, 3 ),
 						nextPosition: new Position( paragraph, 4 )
@@ -848,7 +848,7 @@ describe( 'TreeWalker', () => {
 				];
 			} );
 
-			it( 'should iterate ignoring ELEMENT_END', () => {
+			it( 'should iterate ignoring elementEnd', () => {
 				let iterator = new TreeWalker( { startPosition: rootBeginning, ignoreElementEnd: true } );
 				let i = 0;
 
@@ -859,16 +859,16 @@ describe( 'TreeWalker', () => {
 				expect( i ).to.equal( expected.length );
 			} );
 
-			it( 'should iterate ignoring ELEMENT_END going backward', () => {
+			it( 'should iterate ignoring elementEnd going backward', () => {
 				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 );
@@ -881,61 +881,61 @@ describe( 'TreeWalker', () => {
 			before( () => {
 				expected = [
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img1,
 						previousPosition: new Position( root, 0 ),
 						nextPosition: new Position( img1, 0 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: paragraph,
 						previousPosition: new Position( root, 1 ),
 						nextPosition: new Position( paragraph, 0 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: bold,
 						previousPosition: new Position( paragraph, 0 ),
 						nextPosition: new Position( bold, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'a',
 						previousPosition: new Position( bold, 0 ),
 						nextPosition: new Position( textAbcd, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'b',
 						previousPosition: new Position( textAbcd, 1 ),
 						nextPosition: new Position( textAbcd, 2 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'c',
 						previousPosition: new Position( textAbcd, 2 ),
 						nextPosition: new Position( textAbcd, 3 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'd',
 						previousPosition: new Position( textAbcd, 3 ),
 						nextPosition: new Position( bold, 1 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'y',
 						previousPosition: new Position( paragraph, 1 ),
 						nextPosition: new Position( paragraph, 2 )
 					},
 					{
-						type: 'ELEMENT_START',
+						type: 'elementStart',
 						item: img2,
 						previousPosition: new Position( paragraph, 2 ),
 						nextPosition: new Position( img2, 0 )
 					},
 					{
-						type: 'TEXT',
+						type: 'text',
 						text: 'x',
 						previousPosition: new Position( paragraph, 3 ),
 						nextPosition: new Position( paragraph, 4 )
@@ -943,7 +943,7 @@ describe( 'TreeWalker', () => {
 				];
 			} );
 
-			it( 'should return single characters ignoring ELEMENT_END', () => {
+			it( 'should return single characters ignoring elementEnd', () => {
 				let iterator = new TreeWalker( {
 					startPosition: rootBeginning,
 					singleCharacters: true,
@@ -958,17 +958,17 @@ describe( 'TreeWalker', () => {
 				expect( i ).to.equal( expected.length );
 			} );
 
-			it( 'should return single characters ignoring ELEMENT_END going backward', () => {
+			it( 'should return single characters ignoring elementEnd going backward', () => {
 				let iterator = new 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 {
@@ -992,11 +992,11 @@ function expectValue( value, expected, options = {} ) {
 	expect( value.previousPosition ).to.deep.equal( expectedPreviousPosition );
 	expect( value.nextPosition ).to.deep.equal( expectedNextPosition );
 
-	if ( value.type == 'TEXT' ) {
+	if ( value.type == 'text' ) {
 		expectText( value, expected );
-	} else if ( value.type == 'ELEMENT_START' ) {
+	} else if ( value.type == 'elementStart' ) {
 		expectStart( value, expected );
-	} else if ( value.type == 'ELEMENT_END' ) {
+	} else if ( value.type == 'elementEnd' ) {
 		expectEnd( value, expected );
 	}
 }