Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevemao/bling.js
Because you want the $ of jQuery without the jQuery
https://github.com/stevemao/bling.js
Last synced: 6 days ago
JSON representation
Because you want the $ of jQuery without the jQuery
- Host: GitHub
- URL: https://github.com/stevemao/bling.js
- Owner: stevemao
- Created: 2016-08-04T07:54:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-04T07:58:59.000Z (over 8 years ago)
- Last Synced: 2024-11-07T13:53:14.643Z (about 2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# bling.js
Because you want the $ of jQuery without the jQuery.
------------------------------------
You may be interested in bling.js if you get tired of the `[].slice.call( document.querySelectorAll('.foo'), function(){ … ` rodeo. It does this:
```js
// forEach over the qSA result, directly.
document.querySelectorAll('input').forEach(el => /* ... */);// on() rather than addEventListener()
document.body.on('dblclick', evt => /* ... */);// classic $ + on()
$('p').on('click', el => /* ... */);
```It doesn't do anything else. This is **not** a jQuery equivalent.
#### Notes:
* `on()` works on elements, `document`, `window`, and results from `querySelector` & `querySelectorAll`.
* `$` is qSA so if you're grabbing a single element you'll have to `[0]` it.
* Bling plays well with authoring ES6
* Resig explored this stuff a while ago: [github.com/jeresig/nodelist](http://github.com/jeresig/nodelist)
* Bling doesn't work on Android 2.3 or iOS 5.0. Works everywhere else including IE8 (assuming Function.bind)#### Nerdy implementation notes:
* The NodeList prototype usually inherits from Object, so we move it to Array.
* I'm curious how ES6/7 would let a NodeList be iterable and inherit from EventTarget
* Setting `Node.prototype.on = EventTarget.prototype.addEventListener` is awesome. It works in Chrome/FF but not yet in IE/Safari.
* I haven't set up any off() or trigger() to map to `dispatchEvent` & `removeEventListener`. I'm OK with that.
* I'm using [semi-standard](https://github.com/Flet/semistandard) for style. I tried standard sans-semicolons, but can't get used to it.