Skip to content

Instantly share code, notes, and snippets.

@ChiChou
Forked from paulirish/bling.js
Last active August 8, 2024 04:04
Show Gist options
  • Save ChiChou/ec48fd416abc14bdf232 to your computer and use it in GitHub Desktop.
Save ChiChou/ec48fd416abc14bdf232 to your computer and use it in GitHub Desktop.
/**
* bling.js
*/
window.$ = document.querySelectorAll.bind(document);
window.$id = document.getElementById.bind(document);
Array.prototype.each = Array.prototype.forEach;
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, delegate, fn) {
this.each(function(e) {
e.on(name, delegate, fn);
});
return this;
};
Node.prototype.on = window.on = function(names, fn) {
var self = this;
names.split(' ').each(function(name) {
self.addEventListener(name, fn);
});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment