Skip to content

Instantly share code, notes, and snippets.

@abhijithvijayan
Forked from paulirish/bling.js
Last active June 2, 2019 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijithvijayan/99b72cef2d9f0acb365dca1a8e239998 to your computer and use it in GitHub Desktop.
Save abhijithvijayan/99b72cef2d9f0acb365dca1a8e239998 to your computer and use it in GitHub Desktop.
bling dot js

bling.js

Because you want the $ of jQuery without the jQuery.


/* bling.js */
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = NodeList.prototype.addEventListener = function (name, fn) {
this.forEach(function (elem, i) {
elem.on(name, fn);
});
}
export { $, $$ };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment