|
Use goog.dom.getElement instead.
Alias for getElement.
|
code » | |||||
goog.dom.$$(opt_tag, opt_class, opt_el)
⇒ {length: number}
Use goog.dom.getElementsByTagNameAndClass instead.
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.createDom instead.
Alias for
createDom.
Arguments:
Returns:
Reference to a DOM node.
|
code » | |||||
goog.dom.append(parent, var_args)
Appends a node with text or other nodes.
Arguments:
|
code » | |||||
goog.dom.appendChild(parent, child)
Appends a child to a node.
|
code » | |||||
goog.dom.append_(doc, parent, args, startIndex)
Appends a node with text or other nodes.
|
code » | |||||
goog.dom.findCommonAncestor.apply()
No description.
|
code » | |||||
|
Determines if the given node can contain children, intended to be used for
HTML generation.
IE natively supports node.canHaveChildren but has inconsistent behavior.
Prior to IE8 the base tag allows children and in IE9 all nodes return true
for canHaveChildren.
In practice all non-IE browsers allow you to add children to any node, but
the behavior is inconsistent:
var a = document.createElement('br');
a.appendChild(document.createTextNode('foo'));
a.appendChild(document.createTextNode('bar'));
console.log(a.childNodes.length); // 2
console.log(a.innerHTML); // Chrome: "", IE9: "foobar", FF3.5: "foobar"
TODO(user): Rename shouldAllowChildren() ?
|
code » | |||||
|
Prefer the standardized (http://www.w3.org/TR/selectors-api/), native and
fast W3C Selectors API. However, the version of WebKit that shipped with
Safari 3.1 and Chrome has a bug where it will not correctly match mixed-
case class name selectors in quirks mode.
|
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
textNode's parent is an ancestor of 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
createDom.
|
code » | |||||
|
Creates a new element.
|
code » | |||||
|
Create a table.
|
code » | |||||
|
Create a table.
|
code » | |||||
goog.dom.createTextNode(content)
⇒ 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
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
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 » | |||||
|
Determines the active element in the given document.
|
code » | |||||
|
Walks up the DOM hierarchy returning the first ancestor that passes the
matcher function.
Arguments:
Returns:
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:
The first ancestor that matches the passed criteria, or null if none match.
|
code » | |||||
|
Returns an array containing just the element children of the given element.
|
code » | |||||
|
use goog.dom.isCss1CompatMode instead.
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
getDocumentScrollElement.
|
code » | |||||
|
Helper for
getDocumentScroll.
Arguments:
Returns:
Object with values 'x' and 'y'.
|
code » | |||||
|
Gets the DomHelper object for the document where the element resides.
Arguments:
Returns:
The DomHelper.
|
code » | |||||
|
Alias for getElementById. If a DOM node is passed in then we just return
that.
|
code » | |||||
|
Returns the first element with the provided className.
|
code » | |||||
goog.dom.getElementsByClass(className, opt_el)
⇒ {length: number}
Returns an array of all the elements with the provided className.
|
code » | |||||
goog.dom.getElementsByTagNameAndClass(opt_tag, opt_class, opt_el)
⇒ {length: number}
Looks up elements by both tag and class name, using browser native functions
(
querySelectorAll, getElementsByTagName or
getElementsByClassName) where possible. This function
is a useful, if limited, way of collecting a list of DOM elements
with certain characteristics. 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.
Arguments:
Returns:
{length: number}
Array-like list of elements (only a length property and numerical indices are guaranteed to exist).
|
code » | |||||
goog.dom.getElementsByTagNameAndClass_(doc, opt_tag, opt_class, opt_el)
⇒ {length: number}
Helper for
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
node.
|
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:
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 » | |||||
|
Use goog.dom.getDocumentScroll instead.
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 previous node in source order from the given node.
|
code » | |||||
|
Returns the text content of the current node, without markup.
Unlike
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 » | |||||
goog.dom.getTextContent_(node, buf, normalizeWhitespace)
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
getViewportSize.
Arguments:
Returns:
Object with values 'width' and 'height'.
|
code » | |||||
|
Gets the window object associated with the given document.
|
code » | |||||
|
Helper for
getWindow.
|
code » | |||||
|
Converts an HTML string into a document fragment.
|
code » | |||||
|
Helper for
htmlToDocumentFragment.
|
code » | |||||
goog.dom.insertChildAt(parent, child, index)
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 » | |||||
goog.dom.insertSiblingAfter(newNode, refNode)
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 » | |||||
goog.dom.insertSiblingBefore(newNode, refNode)
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 » | |||||
|
Whether the object looks like an Element.
Arguments:
Returns:
Whether the object looks like an Element.
|
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.
|
code » | |||||
|
Whether the object looks like a DOM node.
Arguments:
Returns:
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:
Whether the variable is a window.
|
code » | |||||
goog.dom.removeChildren(node)
Removes all the child nodes on a DOM node.
Arguments:
|
code » | |||||
|
Removes a node from its parent.
|
code » | |||||
goog.dom.replaceNode(newNode, oldNode)
Replaces a node in the DOM tree. Will do nothing if
oldNode has no
parent.
|
code » | |||||
goog.dom.setFocusableTabIndex(element, enable)
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 » | |||||
goog.dom.setProperties(element, properties)
Sets multiple properties on a node.
|
code » | |||||
goog.dom.setTextContent(element, text)
Cross-browser function for setting the text content of an element.
|
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 » | |
|
Cached default DOM helper.
|
Code » |