-
Notifications
You must be signed in to change notification settings - Fork 0
Dom Utils
Rangy uses some DOM helper functions internally, and provides these functions to other code via rangy.dom
.
Square brackets around one or more function or method parameters indicate that the parameter(s) is/are optional.
Constructor function that creates an object representing a position within a document in terms of a DOM node and an offset within that node. For character nodes such as text, comment and CDATA nodes, this is a character offset within their text content. For all other nodes, the offset is the index of a child node within that node.
DomPosition
objects have the following methods:
-
inspect()
: returns a string representation of the position, such as[DomPosition(<P>:1)]
. -
equals(DomPosition pos)
: returns a Boolean indicating whether this position is identical to the specified position.
Compares two positions (A and B) within a document and returns -1 if A is earlier in the document than B, 0 if A and B are identical or 1 if A is later in the document than B.
Returns a reference to the body element of the specified document.
Returns a reference to the outermost node contained within ancestor
that is an ancestor of node
. Whether node
is considered an ancestor of itself and is therefore a valid return value is determined by selfIsAncestor
.
Returns a reference to the innermost node that is an ancestor of both node1
and node2
.
Returns a reference to the document that contains node
.
Returns the index of the specified node within its parent.
Returns the length of the specified node. For text and comment nodes, this is the length of the text the node represents. For any other node type, this is the number of child nodes of the node.
Returns a reference to the Window object that contains node
's document.
Inserts the node
immediately after precedingNode
in the document and returns a reference to the inserted node.
Returns a string representation of the node for debugging purposes.
Returns a Boolean indicating whether ancestor
is an ancestor of descendant
.
Returns a Boolean indicating whether ancestor
equals or is an ancestor of descendant
.
Returns true
if node
is either a text node, comment node or CDATA node and false
otherwise.
Splits a character node into two at the character index specified by index
and returns a reference to the newly created node, which is the node representing the content after the splitting point.
Returns the Window object for the specified <iframe>
element.
Returns the Document object for the specified <iframe>
element.
Returns the root node for node
.
Returns the computed style property propName
for element el
.
Returns a Document object that varies depending of the parameter supplied:
- If
obj
is an iframe element, return the content document for the iframe - If
obj
is a Window, return the document for that window - If
obj
is any other DOM node, return the node's owner document
Removes node
from its parent.