Skip to content

Instantly share code, notes, and snippets.

@a-eid
Created June 28, 2017 16:20
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 a-eid/d4e8abd801b1619824b814a9ef035b92 to your computer and use it in GitHub Desktop.
Save a-eid/d4e8abd801b1619824b814a9ef035b92 to your computer and use it in GitHub Desktop.
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);
});
};
const remove = selector => {
$$(selector).forEach( x => x.remove() )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment