selly

0.1.0 • Public • Published

selly

selly on NPM Standard JavaScript Style

Convenient and optimized DOM element selection.

Install

$ npm i selly --save

Use

import select from 'selly'
 
// optimized
const body = selly('body')                // select document.body
const head = selly('head')                // select document.head
 
const byID = selly('#one')                // select by ID
const byClass = selly('.many')            // select by class (returns an Array)
 
const byTag = selly('div')                // select by tag name (returns an Array)
 
// unoptimized (querySelectorAll)
const byAttr = selly('[attribute]')       // select by attribute (returns an Array)
 
// using a scope element (defaults to document)
const meta = selly('meta', head)
 
// nested
const scripts = selly('script', selly('body'))

Note that as of v0.1.0, if only 1 element matches a selector passed to selly, that element will be returned (instead of an Array containing only 1 item).

const unique = selly('.unique')
 
// since only 1 element matched, logs HTMLElement not [HTMLElement]
console.log(unique)

License

MIT. © 2017 Michael Cavalea

Readme

Keywords

none

Package Sidebar

Install

npm i selly

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • callmecavs