Created
September 25, 2021 11:15
-
-
Save JTRNS/571383ec963ff6155a8ee4cba52aef5b to your computer and use it in GitHub Desktop.
A more shiny variation of the popular bling dot js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* blingbling.js */ | |
window.$ = document.querySelector.bind(document); | |
window.$$ = document.querySelectorAll.bind(document); | |
HTMLElement.prototype.$ = function (selector) { | |
return this.querySelector(selector); | |
} | |
HTMLElement.prototype.$$ = function (selector) { | |
return this.querySelectorAll(selector); | |
} | |
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); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment