goog.dom.DomHelper |
opt_document
: Document=
Document object to associate with this
DOM helper.
|
Use
goog.dom.DomHelper.prototype.getElement instead.
Alias for getElement .
|
code » | |||||
![]()
Use DomHelper getElementsByTagNameAndClass.
Alias for
getElementsByTagNameAndClass .
Arguments:
Returns: {length: number
} Array-like list of elements (only a length
property and numerical indices are guaranteed to exist).
|
code » | |||||
Use
goog.dom.DomHelper.prototype.createDom instead.
Alias for createDom .
Arguments:
Returns: !Element
Reference to a DOM node.
|
code » | |||||
![]()
Appends a node with text or other nodes.
Arguments:
|
code » | |||||
![]()
Appends a child to a node.
|
code » | |||||
Determines if the given node can contain children, intended to be used for
HTML generation.
|
code » | |||||
Compares the document order of two nodes, returning 0 if they are the same
node, a negative number if node1 is before node2, and a positive number if
node2 is before node1. Note that we compare the order the tags appear in the
document so in the tree text the B node is considered to be
before the I node.
|
code » | |||||
Whether a node contains another 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: !Element
Reference to a DOM node.
|
code » | |||||
Creates a new element.
|
code » | |||||
Create a table.
|
code » | |||||
![]()
Creates a new text node.
|
code » | |||||
Find the deepest common ancestor of the given nodes.
Arguments:
Returns: Node
The common ancestor of the nodes, or null if there is none.
null will only be returned if two or more of the nodes are from different
documents.
|
code » | |||||
Finds the first descendant node that matches the filter function. This does
a depth first search.
|
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.
|
code » | |||||
Determines the active element in the given document.
Arguments:
Returns: Element
The active element.
|
code » | |||||
Walks up the DOM hierarchy returning the first ancestor that passes the
matcher function.
Arguments:
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
class name. If the passed element matches the specified criteria, the
element itself is returned.
|
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.
Arguments:
Returns: Element
The first ancestor that matches the passed criteria, or
null if no match is found.
|
code » | |||||
Returns an array containing just the element children of the given element.
|
code » | |||||
Gets the document object being used by the dom library.
Returns: !Document
Document object.
|
code » | |||||
Calculates the height of the document.
Returns: number
The height of the document.
|
code » | |||||
Gets the document scroll distance as a coordinate object.
Returns: !goog.math.Coordinate
Object with properties 'x' and 'y'.
|
code » | |||||
Gets the document scroll element.
Returns: !Element
Scrolling element.
|
code » | |||||
Gets the dom helper object for the document where the element resides.
Arguments:
Returns: !goog.dom.DomHelper
The DomHelper.
|
code » | |||||
Alias for
getElementById . If a DOM node is passed in then we just
return that.
|
code » | |||||
Returns the first element we find matching the provided class name.
|
code » | |||||
![]()
Returns an array of all the elements with the provided className.
|
code » | |||||
![]()
Looks up elements by both tag and class name, using browser native functions
(
querySelectorAll , getElementsByTagName or
getElementsByClassName ) where possible. The returned array is a live
NodeList or a static list depending on the code path taken.
Arguments:
Returns: {length: number
} Array-like list of elements (only a length
property and numerical indices are guaranteed to exist).
|
code » | |||||
Returns the first child node that is an element.
|
code » | |||||
Cross browser function for getting the document element of an iframe.
|
code » | |||||
Cross browser function for getting the window of a frame or iframe.
|
code » | |||||
Returns the last child node that is an element.
|
code » | |||||
Returns the first next sibling that is an element.
|
code » | |||||
Returns the next node in source order from the given node.
|
code » | |||||
Returns the node at a given offset in a parent node. If an object is
provided for the optional third parameter, the node and the remainder of the
offset will stored as properties of this object.
Arguments:
Returns: Node
The node at the given offset.
|
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.
|
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
goog.dom.getNodeTextLength .
|
code » | |||||
Gets the outerHTML of a node, which islike innerHTML, except that it
actually contains the HTML of the node itself.
|
code » | |||||
Returns the owner document for a node.
|
code » | |||||
Returns an element's parent, if it's an Element.
|
code » | |||||
Returns the first previous sibling that is an element.
|
code » | |||||
Returns the previous node in source order from the given node.
|
code » | |||||
Gets an element by id, asserting that the element is found.
This is used when an element is expected to exist, and should fail with
an assertion error if it does not (if assertions are enabled).
|
code » | |||||
Ensures an element with the given className exists, and then returns the
first element with the provided className.
|
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.
|
code » | |||||
Gets the dimensions of the viewport.
Arguments:
Returns: !goog.math.Size
Object with values 'width' and 'height'.
|
code » | |||||
Gets the window object associated with the document.
Returns: !Window
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
htmlString only generates a single node. If the
htmlString generates multiple nodes then these are put inside a
DocumentFragment .
|
code » | |||||
![]()
Insert a child at a given index. If index is larger than the number of child
nodes that the parent currently has, the node is inserted as the last child
node.
|
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: boolean
True if in CSS1-compatible mode.
|
code » | |||||
Whether the object looks like an Element.
Arguments:
Returns: boolean
Whether the object looks like an Element.
|
code » | |||||
Returns true if the element can be focused, i.e. it has a tab index that
allows it to receive keyboard focus (tabIndex >= 0), or it is an element
that natively supports keyboard focus.
|
code » | |||||
Returns true if the element has a tab index that allows it to receive
keyboard focus (tabIndex >= 0), false otherwise. Note that some elements
natively support keyboard focus, even if they have no tab index.
|
code » | |||||
Whether the object looks like a DOM node.
Arguments:
Returns: boolean
Whether the object looks like a DOM node.
|
code » | |||||
Returns true if the object is a
NodeList . To qualify as a NodeList,
the object must have a numeric length property and an item function (which
has type 'string' on IE for some reason).
|
code » | |||||
Returns true if the specified value is a Window object. This includes the
global window for HTML pages, and iframe windows.
Arguments:
Returns: boolean
Whether the variable is a window.
|
code » | |||||
![]()
Removes all the child nodes on a DOM node.
Arguments:
|
code » | |||||
Removes a node from its parent.
|
code » | |||||
![]()
Replaces a node in the DOM tree. Will do nothing if
oldNode has no
parent.
|
code » | |||||
![]()
Sets the document object.
Arguments:
|
code » | |||||
![]()
Enables or disables keyboard focus support on the element via its tab index.
Only elements for which
goog.dom.isFocusableTabIndex returns true
(or elements that natively support keyboard focus, like form elements) can
receive keyboard focus. See http://go/tabindex for more info.
|
code » | |||||
![]()
Sets a number of properties on a node.
|
code » | |||||
![]()
Sets the text content of a node, with cross-browser support.
|
code » |
![]()
Reference to the document object to use
|
Code » |