@akwaba/dom
v1.1.2
Published
A collection of DOM utility methods
Downloads
11
Readme
@akwaba/dom
Overview
A collection of DOM utility methods.
Published on npmjs.com as @akwaba/dom
.
API
ancestors(element, selector = "div")
- Returns the ancestors of the given element that match the specified selectorchildren(element, selector = "*")
- Returns the children of the given element that match the specified selectorcollect(element, property)
- Recursively collects all the element's parent, siblings or child elements that match the specified propertycumulativeOffset(element)
- Returns the cumulative top and left offsets for this elementdimensions(element)
- Returns the dimensions of the given elementheight(element)
- Returns the height of the given elementmatchesSelector(element, selector)
- Returns true if the given element matches the specified selector; otherwise, returns falseparents(element)
- Returns the parents of the given element by recursively collecting each "parentNode" element up to the document elementselect(expression, scope)
- Returns an array of the nodes that match the specified expression from the given scopeviewport()
- Returns the dimensions and offsets of the current viewportwidth(element)
- Returns the width of the given element
DOM Storage API
storage.getStorage(element)
- Retrieves the storage entry for the given elementstorage.store(element, key, value)
- Stores a key/value pair of content for the given elementstorage.retrieve(element, key)
- Retrieves the value of the key specified in this element's storage unit
Usage
import DOM from '@akwaba/dom';
const dimensions = DOM.dimensions("container");
console.log(dimensions); // { width: 400, height: 300 }
License
Copyright (c) 2019 Akwaba Systems, Inc.