83.2. OrNone, OrNode, OrElement modifiers
Prev | 83. selectNode | Next

### 83.2. OrNone, OrNode, OrElement modifiers

The `OrNone`, `OrNode`, `OrElement` modifiers may be used to specify fallback behaviors for `selectNode` commands which otherwise would fail and therefore would do nothing at all.

OrNone

  If specified `selectNode` command fails to select something new, current selection is canceled.

  Example: let explicitly selected node be an empty element. In such case `selectNode child` fails and therefore, does nothing at all. But `selectNode childOrNone` succeeds and cancels current selection.

OrNode

  If there is no explicit or implicit node selection to work with, command `selectNode` explicitly selects textual node containing caret.

  Example: caret is contained in a `para` and there no explicit selection. In such case, `selectNode.parent` fails and therefore, does nothing at all. But `selectNode.parentOrNode` succeeds and selects the textual node containing the caret.

OrElement

  If there is no explicit or implicit node selection to work with, command `selectNode` explicitly selects element containing caret.

  Example: caret is contained in a `para` and there no explicit selection. In such case, `selectNode.parent` fails and therefore, does nothing at all. But `selectNode.parentOrElement` succeeds and selects the `para` containing the caret.

It does not make sense to use `OrNone`, `OrNode`, `OrElement` modifiers and `[implicitNode]`, `[implicitElement]` options in the same `selectNode` command. In such case, the `OrNone`, `OrNode`, `OrElement` modifiers are simply ignored.

Prev | Up | Next
83.1. List of element names or node types | Home | 84. selectNodeAt