Module: decks/ui/dom

decks/ui/dom

DOM manipulation helper module to encapsulate browser and DOM API version differences.
Source:

Members

<static> defaultOverflowTolerance

Default tolerance value for isOverflowed methods
Source:

Methods

<static> append(parent, child) → {undefined}

Appends a child element to a parent element
Parameters:
Name Type Description
parent
child
Source:
Returns:
Type
undefined

<static> attr(element, name, value) → {undefined}

Gets or sets an Element attribute value
Parameters:
Name Type Description
element
name
value
Source:
Returns:
Type
undefined

<static> create(type) → {Element}

Creates a DOM element by name (e.g. "div").
Parameters:
Name Type Description
type String the type of DOM element to create (e.g. "div")
Source:
Returns:
- the DOM element
Type
Element

<static> empty(element) → {undefined}

Empties an element by removing all children
Parameters:
Name Type Description
element
Source:
Returns:
Type
undefined

<static> getAttr(element, name) → {undefined}

Gets an Element's attribute value by name
Parameters:
Name Type Description
element
name
Source:
Returns:
Type
undefined

<static> hasClass(element, className) → {undefined}

Indicates if an Element has the given class
Parameters:
Name Type Description
element
className
Source:
Returns:
Type
undefined

<static> html(element, data) → {String}

Gets or sets an element's innerHTML.
Parameters:
Name Type Argument Description
element Element the Element for which to get or set HTML.
data String <nullable>
the HTML to set, or if not specified, the method will return the HTML.
Source:
Returns:
- the element's innerHTML
Type
String

<static> isOverflowed(element, tolerance) → {boolean}

Indicates if an element is overflowing it's parent in any direction.
Parameters:
Name Type Argument Default Description
element Element element to check
tolerance number <optional>
<nullable>
2 tolerance to add to element.clientHeight and element.clientWidth
Source:
Returns:
- whether element is overflowed
Type
boolean

<static> isOverflowedX(element, tolerance) → {boolean}

Indicates if an element is overflowing it's parent in the horizontal direction.
Parameters:
Name Type Argument Default Description
element Element element to check
tolerance number <optional>
<nullable>
2 tolerance to add to element.clientWidth
Source:
Returns:
- whether element is overflowed horizontally
Type
boolean

<static> isOverflowedY(element, tolerance) → {boolean}

Indicates if an element is overflowing it's parent in the vertical direction.
Parameters:
Name Type Argument Default Description
element Element element to check
tolerance number <optional>
<nullable>
2 tolerance to add to element.clientHeight
Source:
Returns:
- whether element is overflowed vertically
Type
boolean

<static> nearest(point, elements) → {Element}

Get the element whose bounding rect top/left is nearest to the given point in distance.
Parameters:
Name Type Description
point Object the point to compare all elements to (in top/left or x/y)
elements Array.<Element> | NodeList the elements to check
Source:
Returns:
- the element whose top/left is nearest to point
Type
Element

<static> parse(html, options) → {Element|NodeList}

Parses an HTML string, and returns the resulting Element or Elements.
Parameters:
Name Type Argument Default Description
html string the HTML string
options Object <optional>
<nullable>
{} additional options
Properties
Name Type Argument Default Description
multiple boolean <optional>
<nullable>
false whether to return a all top-level sibling elements
Source:
Returns:
- the resulting Element or NodeList of elements
Type
Element | NodeList

<static> prepend(parent, child) → {undefined}

Prepends a child element in a parent element
Parameters:
Name Type Description
parent
child
Source:
Returns:
Type
undefined

<static> query(selector, context) → {NodeList}

Wrapper for querySelectorAll
Parameters:
Name Type Argument Default Description
selector string DOM selector
context HTMLElement <optional>
<nullable>
document context element for DOM query
Source:
Returns:
Type
NodeList

<static> querySingle(selector, context) → {undefined}

Wrapper for querySelector
Parameters:
Name Type Argument Default Description
selector string DOM selector
context Element <optional>
<nullable>
document context element for DOM query
Source:
Returns:
Type
undefined

<static> remove(parent, child) → {undefined}

Removes a child element from a parent element, or removes the parent element from its parent if no child specified.
Parameters:
Name Type Description
parent
child
Source:
Returns:
Type
undefined

<static> setAttr(element, name, value) → {undefined}

Sets an Element's attribute value by name
Parameters:
Name Type Description
element
name
value
Source:
Returns:
Type
undefined

<static> text(element, data) → {undefined}

Gets or sets the textContent/innerText of the Element
Parameters:
Name Type Description
element
data
Source:
Returns:
Type
undefined