Skip to content

Instantly share code, notes, and snippets.

@michaelwhyte
Created April 7, 2018 01:42
Show Gist options
  • Save michaelwhyte/e32670d66f6e871b35086558557915fa to your computer and use it in GitHub Desktop.
Save michaelwhyte/e32670d66f6e871b35086558557915fa to your computer and use it in GitHub Desktop.
// based on: https://gist.github.com/paulirish/12fb951a8b893a454b32
// which is based on: https://gist.github.com/paulirish/12fb951a8b893a454b32
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; // eslint-disable-line
NodeList.prototype.on = NodeList.prototype.addEventListener = function (name, fn) {
this.forEach((elem) => {
elem.on(name, fn);
});
};
export { $, $$ };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment