Global

Methods

assemble()

assemble a template literal into a string
Source:

attr(el) → {Object}

convert element.attributes NamedNodeMap to a POJO
Parameters:
Name Type Description
el HTMLElement
Source:
Returns:
Type
Object

closest(el, selector) → {HTMLElement|null}

get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
Parameters:
Name Type Description
el HTMLElement
selector string
Source:
Returns:
Type
HTMLElement | null

(generator) collectTextNodes(el, endNode) → {Iterable.HTMLElement}

iterator to collect text nodes from a dom element
Parameters:
Name Type Description
el HTMLElement start element
endNode HTMLElement stop element
Source:
Returns:
iterates over text nodes
Type
Iterable.HTMLElement

createElement(html) → {HTMLElement}

create one HTML element from an html string
Parameters:
Name Type Description
html string e.g. ``
Source:
Returns:
Type
HTMLElement

createFragment(string) → {HTMLElement}

create a document fragment from an html string copied from JSDOM
Parameters:
Name Type Description
string String outerHTML for the new fragment
Source:
Returns:
Document Fragment
Type
HTMLElement

createTextNode(text) → {HTMLElement}

return a text node
Parameters:
Name Type Description
text String textContent for the new text node
Source:
Returns:
Type
HTMLElement

dom() → {HTMLElement}

Tagged template function to convert possibly pretty html to an unpretty document fragment. E.g. dom`<p>foo<\p>`
Parameters:
Name Type Description
... TemplateStringsArray template literal
Source:
Returns:
document fragment
Type
HTMLElement

el() → {HTMLElement}

Tagged template function to convert html to an element. E.g. el`<p>foo</p>`
Parameters:
Name Type Description
... TemplateStringsArray template literal
Source:
Returns:
element
Type
HTMLElement

(generator) filterTextNodes(el, filterFn) → {Iterable.HTMLElement}

collect text nodes that satisfy a filter function
Parameters:
Name Type Description
el HTMLElement
filterFn function
Source:
Returns:
iterates over text nodes
Type
Iterable.HTMLElement

fragmentToHtml(fragment) → {string}

convert a document fragment to html
Parameters:
Name Type Description
fragment HTMLElement document fragment
Source:
Returns:
Type
string

(generator) parentsUntil(childNode, target) → {Iterable.HTMLElement}

iterate over a dom element's parents until a target element or selector is found
Parameters:
Name Type Description
childNode HTMLElement
target HTMLElement | string
Source:
Returns:
Type
Iterable.HTMLElement

spliceChars($el, startIndex, deleteCount) → {HTMLElement}

removes characters from an element, optionally inserting one or more replacements
Parameters:
Name Type Description
$el HTMLElement
startIndex number character-index at which to start the splice
deleteCount number integer counting chars to delete starting at startIndex
...insertions HTMLElement elements to insert at startIndex (if any)
Source:
Returns:
returns the input element
Type
HTMLElement

unpretty() → {string}

Tagged template function to de-format an html string. E.g. unpretty`<p> <foo /> </p>` === '<p><foo></foo></p>'
Parameters:
Name Type Description
... TemplateStringsArray template literal
Source:
Returns:
de-formatted html
Type
string

unwrap(el) → {undefined}

unwrap the contents of an element
Parameters:
Name Type Description
el HTMLElement element to unwrap
Source:
Returns:
Type
undefined