Home

Class goog.dom.DomHelper

Create an instance of a DOM helper with a new document object.

Instance Method Summary
createDom(string tagName, (Object|null|string=) opt_attributes, (goog.dom.Appendable|null|undefined) var_args) ⇒ !Element

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.

createElement(string name) ⇒ !Element

Creates a new element.

createTable(number rows, number columns, boolean= opt_fillWithNbsp) ⇒ !Element

Create a table.

createTextNode(string content) ⇒ !Text

Creates a new text node.

getCompatMode() ⇒ string

Returns the compatMode of the document.

getDocument() ⇒ !Document

Gets the document object being used by the dom library.

getDocumentHeight() ⇒ number

Calculates the height of the document.

getDocumentScroll() ⇒ !goog.math.Coordinate

Gets the document scroll distance as a coordinate object.

getDocumentScrollElement() ⇒ ?Element

Gets the document scroll element.

getElement((Element|null|string) element) ⇒ ?Element

Alias for {@code getElementById}. If a DOM node is passed in then we just return that.

getElementByClass(string className, (Document|Element|null=) opt_el) ⇒ ?Element

Returns the first element we find matching the provided class name.

getElementsByClass(string className, (Document|Element|null=) opt_el) ⇒ {length: number}

Returns an array of all the elements with the provided className.

getElementsByTagNameAndClass(?string= opt_tag, ?string= opt_class, (Document|Element|null=) opt_el) ⇒ {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.

getViewportSize(?Window= opt_window) ⇒ !goog.math.Size

Gets the dimensions of the viewport.

getWindow() ⇒ !Window

Gets the window object associated with the document.

htmlToDocumentFragment(string htmlString) ⇒ !Node

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}.

isCss1CompatMode() ⇒ boolean

Returns true if the browser is in "CSS1-compatible" (standards-compliant) mode, false otherwise.

setDocument(!Document document)

Sets the document object.