Skip to content

Instantly share code, notes, and snippets.

@fael
Created May 24, 2016 11:16
Show Gist options
  • Save fael/538ce89ba26fbbe75ca2162a5d4c536c to your computer and use it in GitHub Desktop.
Save fael/538ce89ba26fbbe75ca2162a5d4c536c to your computer and use it in GitHub Desktop.
// bling.js
var $ = window.$ = document.querySelector.bind(document);
var $$ = window.$$ = 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) {
elem.on(name, fn);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment