# CKEDITOR.dom.walker

class

Utility class to "walk" the DOM inside range boundaries. If the range starts or ends in the middle of the text node, this node will be included as a whole. Outside changes to the range may break the walker.

The walker may return nodes that are not totally included in the range boundaries. Let us take the following range representation, where the square brackets indicate the boundaries:

[<p>Some <b>sample] text</b>


While walking forward into the above range, the following nodes are returned: <p>, "Some ", <b> and "sample". Going backwards instead we have: "sample" and "Some ". So note that the walker always returns nodes when "entering" them, but not when "leaving" them. The guard function is instead called both when entering and when leaving nodes.

## Properties

• ### evaluator : FunctionCKEDITOR.dom.walker#evaluator

A function executed for every matched node to check whether it is to be considered in the walk or not. If not provided, all matched nodes are considered good.

If the function returns false, the node is ignored.

• ### guard : FunctionCKEDITOR.dom.walker#guard

A function executed for every node the walk passes by to check whether the walk is to be finished. It is called both when entering and when exiting nodes, as well as for the matched nodes.

If this function returns false, the walking ends and no more nodes are evaluated.

• ### _ : ObjectCKEDITOR.dom.walker#_

private

Defaults to {}

• ### validEmptyBlockContainers : ObjectCKEDITOR.dom.walker#validEmptyBlockContainers

since 4.5.0 static

A hash of element names which in browsers that do not need <br> fillers can be selection containers despite being empty.

## Methods

• ### constructor( range ) → walkerCKEDITOR.dom.walker#constructor

Creates a walker class instance.

#### Parameters

range : range

The range within which to walk.

#### Returns

walker
• ### checkBackward() → BooleanCKEDITOR.dom.walker#checkBackward

Check all nodes on the left, executing the evaluation function.

#### Returns

Boolean

false if the evaluator function returned false for any of the matched nodes. Otherwise true.

• ### checkForward() → BooleanCKEDITOR.dom.walker#checkForward

Checks all nodes on the right, executing the evaluation function.

#### Returns

Boolean

false if the evaluator function returned false for any of the matched nodes. Otherwise true.

• ### end()CKEDITOR.dom.walker#end

Stops walking. No more nodes are retrieved if this function is called.

• ### lastBackward() → nodeCKEDITOR.dom.walker#lastBackward

Executes a full walk backwards (to the left), until no more nodes are available, returning the last valid node.

#### Returns

node

The last node on the left or null if no valid nodes are available.

• ### lastForward() → nodeCKEDITOR.dom.walker#lastForward

Executes a full walk forward (to the right), until no more nodes are available, returning the last valid node.

#### Returns

node

The last node on the right or null if no valid nodes are available.

• ### next() → nodeCKEDITOR.dom.walker#next

Retrieves the next node (on the right).

#### Returns

node

The next node or null if no more nodes are available.

• ### previous() → nodeCKEDITOR.dom.walker#previous

Retrieves the previous node (on the left).

#### Returns

node

The previous node or null if no more nodes are available.

• ### reset()CKEDITOR.dom.walker#reset

Resets the walker.

• ### blockBoundary( customNodeNames ) → FunctionCKEDITOR.dom.walker#blockBoundary

static

Returns a function which checks whether the node is a block boundary. See CKEDITOR.dom.element.isBlockBoundary.

#### Parameters

customNodeNames : Object

#### Returns

Function
• ### bogus( [ isReject ] ) → FunctionCKEDITOR.dom.walker#bogus

static

Returns a function which checks whether the node is a bogus (filler) node from contenteditable element's point of view.

#### Parameters

[ isReject ] : Boolean

Defaults to false

#### Returns

Function
• ### bookmark( [ contentOnly ], [ isReject ] ) → FunctionCKEDITOR.dom.walker#bookmark

static

Returns a function which checks whether the node is a bookmark node or the bookmark node inner content.

#### Parameters

[ contentOnly ] : Boolean

Whether only test against the text content of a bookmark node instead of the element itself (default).

Defaults to false

[ isReject ] : Boolean

Whether to return false for the bookmark node instead of true (default).

Defaults to false

#### Returns

Function
• ### editable( [ isReject ] ) → FunctionCKEDITOR.dom.walker#editable

since 4.3.0 static

Returns a function which checks whether the node can be a container or a sibling of the selection end.

This includes:

• text nodes (but not whitespaces),
• inline elements,
• intersection of CKEDITOR.dtd.$empty and CKEDITOR.dtd.$block (currently it is only <hr>),
• non-editable blocks (special case — such blocks cannot be containers nor siblings, they need to be selected entirely),
• empty blocks which can contain text (old IEs only).

#### Parameters

[ isReject ] : Boolean

Whether to return false for the ignored element instead of true (default).

Defaults to false

#### Returns

Function
• ### empty( [ isReject ] ) → FunctionCKEDITOR.dom.walker#empty

since 4.5.0 static

Returns a function which checks whether the node is empty.

#### Parameters

[ isReject ] : Boolean

Whether to return false for the ignored element instead of true (default).

Defaults to false

#### Returns

Function
• ### ignored( [ isReject ] ) → FunctionCKEDITOR.dom.walker#ignored

since 4.3.0 static

Returns a function which checks whether the node should be ignored in terms of "editability".

This includes:

#### Parameters

[ isReject ] : Boolean

Whether to return false for the ignored element instead of true (default).

Defaults to false

#### Returns

Function
• ### invisible( [ isReject ] ) → FunctionCKEDITOR.dom.walker#invisible

static

Returns a function which checks whether the node is invisible in the WYSIWYG mode.

#### Parameters

[ isReject ] : Boolean

Defaults to false

#### Returns

Function

static

• ### nodeType( type, [ isReject ] ) → FunctionCKEDITOR.dom.walker#nodeType

static

Returns a function which checks whether the node type is equal to the passed one.

#### Parameters

type : Number
[ isReject ] : Boolean

Defaults to false

#### Returns

Function
• ### temp( [ isReject ] ) → FunctionCKEDITOR.dom.walker#temp

since 4.3.0 static

Returns a function which checks whether the node is a temporary element (element with the data-cke-temp attribute) or its child.

#### Parameters

[ isReject ] : Boolean

Whether to return false for the temporary element instead of true (default).

Defaults to false

#### Returns

Function
• ### whitespaces( [ isReject ] ) → FunctionCKEDITOR.dom.walker#whitespaces

static

Returns a function which checks whether the node is a text node containing only whitespace characters.

#### Parameters

[ isReject ] : Boolean

Defaults to false

#### Returns

Function