Enumeration

Node

static

number

Node type constants. https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType

Value

ELEMENT_NODE

TEXT_NODE

COMMENT_NODE

DOCUMENT_POSITION_CONTAINED_BY

Properties

HTML_NS

constant   static

Required name space for HTML elements.

Node

static

number

Node type constants. https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType

Value

ELEMENT_NODE

TEXT_NODE

COMMENT_NODE

DOCUMENT_POSITION_CONTAINED_BY

SVG_NS

constant   static

Required name space for SVG elements.

constant   static

Required name space for XLINK elements.

Methods

addClass

static

addClass(element, className) returns boolean

Add a CSS class to a element. Similar to Closure's goog.dom.classes.add, except it handles SVG elements.

Parameter

element

Element

DOM element to add class to.

Value must not be null.

className

string

Name of class to add.

Returns

boolean True if class was added, false if already present.

containsNode

static

containsNode(parent, descendant) returns boolean

Whether a node contains another node.

Parameter

parent

Node

The node that should contain the other node.

Value must not be null.

descendant

Node

The node to test presence of.

Value must not be null.

Returns

boolean Whether the parent node contains the descendant node.

createSvgElement

static

createSvgElement(name, attrs, parent) returns SVGElement

Helper method for creating SVG elements.

Parameter

name

string

Element's tag name.

attrs

Object

Dictionary of attribute names and values.

Value must not be null.

parent

Element

Optional parent on which to append the element.

Returns

non-null SVGElement Newly created SVG element.

getTextWidth

static

getTextWidth(textElement) returns number

Gets the width of a text element, caching it in the process.

Parameter

textElement

Element

An SVG 'text' element.

Value must not be null.

Returns

number Width of element.

hasClass

static

hasClass(element, className) returns boolean

Checks if an element has the specified CSS class. Similar to Closure's goog.dom.classes.has, except it handles SVG elements.

Parameter

element

Element

DOM element to check.

Value must not be null.

className

string

Name of class to check.

Returns

boolean True if class exists, false otherwise.

insertAfter

static

insertAfter(newNode, refNode)

Insert a node after a reference node. Contrast with node.insertBefore function.

Parameter

newNode

Element

New element to insert.

Value must not be null.

refNode

Element

Existing element to precede new node.

Value must not be null.

removeClass

static

removeClass(element, className) returns boolean

Remove a CSS class from a element. Similar to Closure's goog.dom.classes.remove, except it handles SVG elements.

Parameter

element

Element

DOM element to remove class from.

Value must not be null.

className

string

Name of class to remove.

Returns

boolean True if class was removed, false if never present.

removeNode

static

removeNode(node) returns Node

Removes a node from its parent. No-op if not attached to a parent.

Parameter

node

Node

The node to remove.

Returns

Node The node removed if removed; else, null.

setCssTransform

static

setCssTransform(element, transform)

Sets the CSS transform property on an element. This function sets the non-vendor-prefixed and vendor-prefixed versions for backwards compatibility with older browsers. See https://caniuse.com/#feat=transforms2d

Parameter

element

Element

Element to which the CSS transform will be applied.

Value must not be null.

transform

string

The value of the CSS transform property.

startTextWidthCache

static

startTextWidthCache()

Start caching text widths. Every call to this function MUST also call stopTextWidthCache. Caches must not survive between execution threads.

stopTextWidthCache

static

stopTextWidthCache()

Stop caching field widths. Unless caching was already on when the corresponding call to startTextWidthCache was made.