Awesome
yocto
yocto is fun, small (min.js ≈1K and min.js.gz ≈ 600B) and experimental library which allows you to chain all the default DOM Element methods and properties like this:
$$$('div')
.style({background: 'red', color: '#fff'})
.setAttribute('data-test', 2)
.addEventListener('click', function(e) { console.log(e) })
.lastElementChild()
.className('last-child')
.querySelectorAll('span')
.style({color: '#0f0'})
.innerHTML()
that's 137 items in the latest Google Chrome, for example.
console.dir($$$.prototype)
additional features
$$$('body') instanceof Array
// true
$$$
can:
- handle all the same selectors as
querySelectorAll
- create element with
$$$('<div/>')
- wrap single element with
$$$(document.body)
- wrap elements collectons like
NodeList
and any other Array-Like objects with$$$(document.body.childNodes)
cross-browser normalization
fuck it.
test & lint
- all:
npm test
- unit (still in progress): open
test/test.html
in your browser or runnpm run-script unit
for testing with PhantomJS - eslint:
npm run-script eslint
- jscs:
npm run-script jscs