npm.io
1.1.3 • Published 7 years ago

corleone

Licence
Apache
Version
1.1.3
Deps
1
Size
67 kB
Vulns
0
Weekly
0
Stars
3

corleone

Travis CI

Small DOM utilities.

Installation

npm install corleone -S

Usage

import dom from 'corleone'

dom.show(dom.query('.container'))

API

show

Shows a given DOM node.

dom.show(dom.query('.container'))
hide

Hides a given DOM node.

dom.hide(dom.query('.container'))
create

Create a DOM node from a string.

const node = dom.create('<div class="container"></div>')
remove

Removes a given DOM node from the DOM tree.

dom.remove(dom.query('.container'))
query

Alias for document.querySelector. If rootEl is passed, rootEl.querySelector is used.

const containerNode = dom.query('.container', [rootEl])
queryAll

Alias for document.querySelectorAll. If rootEl is passed, rootEl.querySelectorAll is used.

const imgNodes = dom.queryAll('img', [rootEl])
offset

Returns coordinates of element relative to document.

const coords = dom.offset(el)
closest

Returns closest parent that matches selector.

const el = dom.closest(el, '.foo')
matches

Work as an alias for Element.prototype.matches.

const doesMatch = dom.matches(el, '.red')

caiogondim.com  ·  GitHub @caiogondim  ·  Twitter @caio_gondim