Alias for 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 » | |||||
Determines if the given node can contain children.
|
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 » | |||||
Utility function to compare the position of two nodes, when
{@code textNode}'s parent is an ancestor of {@code node}. If this entry
condition is not met, this function will attempt to reference a null object.
|
code » | |||||
Utility function to compare the position of two nodes known to be non-equal
siblings.
|
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
Arguments:
Returns:
Reference to a DOM node.
|
code » | |||||
Helper for {@code createDom}.
|
code » | |||||
Creates a new element.
|
code » | |||||
![]() !Text
Creates a new text node.
Arguments:
Returns:
!Text
The new text node.
|
code » | |||||
Find the deepest common ancestor of the given nodes.
|
code » | |||||
Finds the first descendant node that matches the filter function, using
a depth first search. This function offers the most general purpose way
of finding a matching element. You may also wish to consider
{@code goog.dom.query} which can express many matching criteria using
CSS selector expressions. These expressions often result in a more
compact representation of the desired result.
|
code » | |||||
Finds all the descendant nodes that match the filter function, using a
a depth first search. This function offers the most general-purpose way
of finding a set of matching elements. You may also wish to consider
{@code goog.dom.query} which can express many matching criteria using
CSS selector expressions. These expressions often result in a more
compact representation of the desired result.
|
code » | |||||
Finds the first or all the descendant nodes that match the filter function,
using a depth first search.
Arguments:
Returns:
Whether the search is complete or not. True in case findOne is true and the node is found. False otherwise.
|
code » | |||||
Flattens an element. That is, removes it and replace it with its children.
Does nothing if the element is not in the document.
|
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
tag name and/or class name. If the passed element matches the specified
criteria, the element itself is returned.
Arguments:
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 current document.
|
code » | |||||
Calculates the height of the document of the given window.
Function code copied from the opensocial gadget api:
gadgets.window.adjustHeight(opt_height)
|
code » | |||||
Gets the document scroll distance as a coordinate object.
Returns:
Object with values 'x' and 'y'.
|
code » | |||||
Gets the document scroll element.
Returns:
Scrolling element.
|
code » | |||||
Helper for {@code getDocumentScrollElement}.
|
code » | |||||
Helper for {@code getDocumentScroll}.
Arguments:
Returns:
Object with values 'x' and 'y'.
|
code » | |||||
Gets the DomHelper object for the document where the element resides.
Returns:
The DomHelper.
|
code » | |||||
Alias for 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. This function
is a useful, if limited, way of collecting a list of DOM elements
with certain characteristics. {@code goog.dom.query} offers a
more powerful and general solution which allows matching on CSS3
selector expressions, but at increased cost in code size. If all you
need is particular tags belonging to a single class, this function
is fast and sleek.
|
code » | |||||
![]() {length: number}
Helper for {@code getElementsByTagNameAndClass}.
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 a frame or iframe.
|
code » | |||||
Cross-browser function for getting the window of a frame or iframe.
Arguments:
Returns:
The window associated with the given frame.
|
code » | |||||
Returns the last child node that is an element.
|
code » | |||||
Returns the first node that is an element in the specified direction,
starting with {@code node}.
|
code » | |||||
Returns the first next sibling that is an element.
|
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:
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 » | |||||
Gets the page scroll distance as a coordinate object.
Arguments:
Returns:
Object with values 'x' and 'y'.
|
code » | |||||
Returns the first previous sibling that is an element.
|
code » | |||||
Returns the text content of the current node, without markup.
Unlike {@code getTextContent} this method does not collapse whitespaces
or normalize lines breaks.
|
code » | |||||
Returns the text content of the current node, without markup and invisible
symbols. 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 » | |||||
![]()
Recursive support function for text content retrieval.
|
code » | |||||
Gets the dimensions of the viewport.
Gecko Standards mode:
docEl.clientWidth Width of viewport excluding scrollbar.
win.innerWidth Width of viewport including scrollbar.
body.clientWidth Width of body element.
docEl.clientHeight Height of viewport excluding scrollbar.
win.innerHeight Height of viewport including scrollbar.
body.clientHeight Height of document.
Gecko Backwards compatible mode:
docEl.clientWidth Width of viewport excluding scrollbar.
win.innerWidth Width of viewport including scrollbar.
body.clientWidth Width of viewport excluding scrollbar.
docEl.clientHeight Height of document.
win.innerHeight Height of viewport including scrollbar.
body.clientHeight Height of viewport excluding scrollbar.
IE6/7 Standards mode:
docEl.clientWidth Width of viewport excluding scrollbar.
win.innerWidth Undefined.
body.clientWidth Width of body element.
docEl.clientHeight Height of viewport excluding scrollbar.
win.innerHeight Undefined.
body.clientHeight Height of document element.
IE5 + IE6/7 Backwards compatible mode:
docEl.clientWidth 0.
win.innerWidth Undefined.
body.clientWidth Width of viewport excluding scrollbar.
docEl.clientHeight 0.
win.innerHeight Undefined.
body.clientHeight Height of viewport excluding scrollbar.
Opera 9 Standards and backwards compatible mode:
docEl.clientWidth Width of viewport excluding scrollbar.
win.innerWidth Width of viewport including scrollbar.
body.clientWidth Width of viewport excluding scrollbar.
docEl.clientHeight Height of document.
win.innerHeight Height of viewport including scrollbar.
body.clientHeight Height of viewport excluding scrollbar.
WebKit:
Safari 2
docEl.clientHeight Same as scrollHeight.
docEl.clientWidth Same as innerWidth.
win.innerWidth Width of viewport excluding scrollbar.
win.innerHeight Height of the viewport including scrollbar.
frame.innerHeight Height of the viewport exluding scrollbar.
Safari 3 (tested in 522)
docEl.clientWidth Width of viewport excluding scrollbar.
docEl.clientHeight Height of viewport excluding scrollbar in strict mode.
body.clientHeight Height of viewport excluding scrollbar in quirks mode.
Arguments:
Returns:
Object with values 'width' and 'height'.
|
code » | |||||
Helper for {@code getViewportSize}.
Arguments:
Returns:
Object with values 'width' and 'height'.
|
code » | |||||
Gets the window object associated with the given document.
|
code » | |||||
Helper for {@code getWindow}.
|
code » | |||||
Converts an HTML string into a document fragment.
|
code » | |||||
Helper for {@code htmlToDocumentFragment}.
|
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 » | |||||
Returns true if the browser is in "CSS1-compatible" (standards-compliant)
mode, false otherwise.
|
code » | |||||
Returns true if the element has a tab index that allows it to receive
keyboard focus (tabIndex >= 0), false otherwise. Note that form elements
natively support keyboard focus, even if they have no tab index. See
http://go/tabindex for more info.
|
code » | |||||
Whether the object looks like a DOM node.
|
code » | |||||
Returns true if the object is a {@code 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 » | |||||
![]()
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 {@code oldNode} has no
parent.
|
code » | |||||
![]()
Enables or disables keyboard focus support on the element via its tab index.
Only elements for which {@link 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 multiple properties on a node.
|
code » | |||||
![]()
Cross-browser function for setting the text content of an element.
|
code » |
Safari contains is broken, but appears to be fixed in WebKit 522+
|
Code » | |
Whether we know the compatibility mode at compile time.
|
Code » | |
Map of attributes that should be set using
element.setAttribute(key, val) instead of element[key] = val. Used
by goog.dom.setProperties.
|
Code » | |
Map of tags which have predefined values with regard to whitespace.
|
Code » | |
Map of tags whose content to ignore when calculating text length.
|
Code » |