Skip to content

Instantly share code, notes, and snippets.

@Kzumueller
Last active March 18, 2018 19:55
Show Gist options
  • Save Kzumueller/54c43a87113f32877df3a50514f7ce5a to your computer and use it in GitHub Desktop.
Save Kzumueller/54c43a87113f32877df3a50514f7ce5a to your computer and use it in GitHub Desktop.
Pure JS DOMLand shortcuts
// 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