Objectgoog.dom.DomHelper
opt_document
:
Document object to associate with this DOM helper.
|
Alias for {@code getElement}.
Returns:
The element with the given ID, or the node passed in.
|
code » | ||||
![]() {length: number}
Alias for {@code getElementsByTagNameAndClass}.
Returns:
{length: number}
Array-like list of elements (only a length property and numerical indices are guaranteed to exist).
|
code » | ||||
Alias for {@code createDom}.
Returns:
Reference to a DOM node.
|
code » | ||||
![]()
Appends a child to a node.
|
code » | ||||
Whether a node contains another node.
Returns:
Whether the parent node contains the descendent node.
|
code » | ||||
Returns a dom node with a set of attributes. This function accepts varargs
for subsequent nodes to be added. Subsequent nodes will be added to the
first node as childNodes.
So:
createDom('div', null, createDom('p'), createDom('p'));
would return a div with two child paragraphs
An easy way to move all child nodes of an existing element to a new parent
element is:
createDom('div', null, oldElement.childNodes);
which will remove all child nodes from the old element and add them as
child nodes of the new DIV.
Arguments:
Returns:
Reference to a DOM node.
|
code » | ||||
Creates a new element.
|
code » | ||||
![]() !Text
Creates a new text node.
Arguments:
Returns:
!Text
The new text node.
|
code » | ||||
![]() (Node, undefined)
Finds the first descendant node that matches the filter function. This does
a depth first search.
Returns:
(Node, undefined)
The found node or undefined if none is found.
|
code » | ||||
Finds all the descendant nodes that matches the filter function. This does a
depth first search.
|
code » | ||||
Flattens an element. That is, removes it and replace it with its children.
Returns:
The original element, detached from the document tree, sans children, or undefined if the element was already not in the document.
|
code » | ||||
Walks up the DOM hierarchy returning the first ancestor that passes the
matcher function.
Returns:
?Node
DOM node that matched the matcher, or null if there was no match.
|
code » | ||||
Walks up the DOM hierarchy returning the first ancestor that has the passed
tag name and/or class name. If the passed element matches the specified
criteria, the element itself is returned.
Returns:
?Node
The first ancestor that matches the passed criteria, or null if none match.
|
code » | ||||
Returns the compatMode of the document.
Returns:
The result is either CSS1Compat or BackCompat.
|
code » | ||||
Gets the document object being used by the dom library.
Returns:
Document object.
|
code » | ||||
Calculates the height of the document.
Returns:
The height of the document.
|
code » | ||||
Gets the document scroll distance as a coordinate object.
Returns:
Object with properties 'x' and 'y'.
|
code » | ||||
Gets the document scroll element.
Returns:
Scrolling element.
|
code » | ||||
Gets the dom helper object for the document where the element resides.
Returns:
The DomHelper.
|
code » | ||||
Alias for {@code getElementById}. If a DOM node is passed in then we just
return that.
|
code » | ||||
![]() {length: number}
Looks up elements by both tag and class name, using browser native functions
({@code querySelectorAll}, {@code getElementsByTagName} or
{@code getElementsByClassName}) where possible. The returned array is a live
NodeList or a static list depending on the code path taken.
|
code » | ||||
Returns the first child node that is an element.
Returns:
The first child node of {@code node} that is an element.
|
code » | ||||
![]() !HTMLDocument
Cross browser function for getting the document element of an iframe.
Returns:
!HTMLDocument
The frame content document.
|
code » | ||||
Cross browser function for getting the window of a frame or iframe.
Returns:
The window associated with the given frame.
|
code » | ||||
Returns the last child node that is an element.
Returns:
The last child node of {@code node} that is an element.
|
code » | ||||
Returns the first next sibling that is an element.
Returns:
The next sibling of {@code node} that is an element.
|
code » | ||||
Returns the text length of the text contained in a node, without markup. This
is equivalent to the selection length if the node was selected, or the number
of cursor movements to traverse the node. Images & BRs take one space. New
lines are ignored.
Returns:
The length of {@code node}'s text content.
|
code » | ||||
Returns the text offset of a node relative to one of its ancestors. The text
length is the same as the length calculated by
{@code goog.dom.getNodeTextLength}.
Returns:
The text offset.
|
code » | ||||
Returns the owner document for a node.
Returns:
The document owning the node.
|
code » | ||||
Returns the first previous sibling that is an element.
Returns:
The first previous sibling of {@code node} that is an element.
|
code » | ||||
Returns the text contents of the current node, without markup. New lines are
stripped and whitespace is collapsed, such that each character would be
visible.
In browsers that support it, innerText is used. Other browsers attempt to
simulate it via node traversal. Line breaks are canonicalized in IE.
Returns:
The text content.
|
code » | ||||
Gets the dimensions of the viewport.
Arguments:
Returns:
Object with values 'width' and 'height'.
|
code » | ||||
Gets the window object associated with the document.
Returns:
The window associated with the given document.
|
code » | ||||
Converts an HTML string into a node or a document fragment. A single Node
is used if the {@code htmlString} only generates a single node. If the
{@code htmlString} generates multiple nodes then these are put inside a
{@code DocumentFragment}.
|
code » | ||||
![]()
Inserts a new node after an existing reference node (i.e., as the next
sibling). If the reference node has no parent, then does nothing.
|
code » | ||||
![]()
Inserts a new node before an existing reference node (i.e., as the previous
sibling). If the reference node has no parent, then does nothing.
|
code » | ||||
Returns true if the browser is in "CSS1-compatible" (standards-compliant)
mode, false otherwise.
Returns:
True if in CSS1-compatible mode.
|
code » | ||||
Whether the object looks like a DOM node.
Returns:
Whether the object looks like a DOM node.
|
code » | ||||
![]()
Removes all the child nodes on a DOM node.
|
code » | ||||
Removes a node from its parent.
Returns:
?Node
The node removed if removed; else, null.
|
code » | ||||
![]()
Replaces a node in the DOM tree. Will do nothing if {@code oldNode} has no
parent.
|
code » | ||||
![]()
Sets the document object.
Arguments:
|
code » | ||||
![]()
Sets a number of properties on a node.
|
code » | ||||
![]()
Cross browser function for setting the text content of an element.
|
code » |