The goog.editor.node Namespace

.findHighestMatchingAncestor(node, hasProperty)

Search ancestor nodes using a predicate function and returns the topmost ancestor in the chain of consecutive ancestors that satisfies the condition.

node {Node}
The node whose ancestors have to be searched.
hasProperty {function(Node): boolean}
A function that takes a parent node as a parameter and returns true if it meets the criteria.
returns {Node}
The topmost ancestor or null if no ancestor satisfies the predicate function.

.findInChildren(parent, hasProperty)

Search child nodes using a predicate function and return the first node that satisfies the condition.

parent {Node}
The parent node to search.
hasProperty {function(Node):boolean}
A function that takes a child node as a parameter and returns true if it meets the criteria.
returns {?number}
The index of the node found, or null if no node is found.

.findTopMostEditableAncestor(node, criteria)

Finds the top-most DOM node inside an editable field that is an ancestor (or self) of a given DOM node and meets the specified criteria.

node {Node}
The DOM node where the search starts.
criteria {function(Node) : boolean}
A function that takes a DOM node as a parameter and returns a boolean to indicate whether the node meets the criteria or not.
returns {Node}
The DOM node if found, or null.

.getFirstChild(parent)

Version of firstChild that skips nodes that are entirely whitespace and comments.

parent {Node}
The reference node.
returns {Node}
The first child of sibling that is important according to goog.editor.node.isImportant, or null if no such node exists.

.getLastChild(parent)

Version of lastChild that skips nodes that are entirely whitespace or comments. (Normally lastChild is a property of all DOM nodes that gives the last of the nodes contained directly in the reference node.)

parent {Node}
The reference node.
returns {Node}
The last child of sibling that is important according to goog.editor.node.isImportant, or null if no such node exists.

.getLeftMostLeaf(parent)

Get the left-most non-ignorable leaf node of the given node.

parent {Node}
The parent ndoe.
returns {Node}
The left-most non-ignorable leaf node.

.getLength(node)

Returns the length of the text in node if it is a text node, or the number of children of the node, if it is an element. Useful for range-manipulation code where you need to know the offset for the right side of the node.

node {Node}
The node to get the length of.
returns {number}
The length of the node.

.getNextSibling(sibling)

Version of nextSibling that skips nodes that are entirely whitespace or comments.

sibling {Node}
The reference node.
returns {Node}
The closest next sibling to sibling that is important according to goog.editor.node.isImportant, or null if no such node exists.

.getPreviousSibling(sibling)

Version of previoussibling that skips nodes that are entirely whitespace or comments. (Normally previousSibling is a property of all DOM nodes that gives the sibling node, the node that is a child of the same parent, that occurs immediately before the reference node.)

sibling {Node}
The reference node.
returns {Node}
The closest previous sibling to sibling that is important according to goog.editor.node.isImportant, or null if no such node exists.

.getRightMostLeaf(parent)

Get the right-most non-ignorable leaf node of the given node.

parent {Node}
The parent ndoe.
returns {Node}
The right-most non-ignorable leaf node.

.isAllNonNbspWhiteSpace(textNode)

Determine whether a node's text content is entirely whitespace.

textNode {Node}
A node implementing the CharacterData interface (i.e., a Text, Comment, or CDATASection node.
returns {boolean}
Whether the text content of node is whitespace, otherwise false.

.isBlockTag(node)

Checks if node is a block-level html element. The display css property is ignored.

node {Node}
The node to test.
returns {boolean}
Whether the node is a block-level node.

.isEditable(node)

Checks if a node is inside an editable container.

node {Node}
The node to test.
returns {boolean}
Whether the node is in an editable container.

.isEditableContainer(element)

Checks if an element is a top-level editable container (meaning that it itself is not editable, but all its child nodes are editable).

element {Node}
The element to test.
returns {boolean}
Whether the element is a top-level editable container.

.isEmpty(node, opt_prohibitSingleNbsp)

Returns true if the node contains only whitespace and is not and does not contain any images, iframes or embed tags.

node {Node}
The node to check.
opt_prohibitSingleNbsp {boolean=}
By default, this function treats a single nbsp as empty. Set this to true to treat this case as non-empty.
returns {boolean}
Whether the node contains only whitespace.

.isImportant(node)

Determine if a node should be returned by the iterator functions.

node {Node}
An object implementing the DOM1 Node interface.
returns {boolean}
Whether the node is an element, or a text node that is not all whitespace.

.isStandardsMode(node)

Check if the node is in a standards mode document.

node {Node}
The node to test.
returns {boolean}
Whether the node is in a standards mode document.

.skipEmptyTextNodes(node)

Skips siblings of a node that are empty text nodes.

node {Node}
A node. May be null.
returns {Node}
The node or the first sibling of the node that is not an empty text node. May be null.

.splitDomTreeAt(currentNode, opt_secondHalf, opt_root)

Splits off a subtree.

currentNode {!Node}
The starting splitting point.
opt_secondHalf {Node=}
The initial leftmost leaf the new subtree. If null, siblings after currentNode will be placed in the subtree, but no additional node will be.
opt_root {Node=}
The top of the tree where splitting stops at.
returns {!Node}
The new subtree.