Last active
March 18, 2018 19:55
-
-
Save Kzumueller/54c43a87113f32877df3a50514f7ce5a to your computer and use it in GitHub Desktop.
Pure JS DOMLand shortcuts
This file contains hidden or 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
// this is some vile monkey patching, think of it what you will, I find it useful | |
if('undefined' === typeof window.qs) { | |
window.qs = document.querySelector.bind(document); | |
} | |
if('undefined' === typeof window.qsa) { | |
window.qsa = document.querySelectorAll.bind(document); | |
} | |
if('undefined' === typeof Element.prototype.qs) { | |
Element.prototype.qs = Element.prototype.querySelector; | |
} | |
if('undefined' === typeof Element.prototype.qsa) { | |
Element.prototype.qsa = Element.prototype.querySelectorAll; | |
} | |
if('undefined' === typeof Element.prototype.on) { | |
Element.prototype.on = Element.prototype.addEventListener; | |
} | |
if('undefined' === typeof document.on) { | |
document.on = document.addEventListener; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment