mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
add functional shorthands
This commit is contained in:
parent
159c1aa3e3
commit
fc62143eae
5 changed files with 162 additions and 157 deletions
21
utils/shorthands.js
Normal file
21
utils/shorthands.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const query = document.querySelector.bind(document);
|
||||
const queryAll = document.querySelectorAll.bind(document);
|
||||
const byId = document.getElementById.bind(document);
|
||||
const byClass = document.getElementsByClassName.bind(document);
|
||||
const byTag = document.getElementsByTagName.bind(document);
|
||||
|
||||
Node.prototype.query = function (selector) {
|
||||
return this.querySelector(selector);
|
||||
};
|
||||
|
||||
Node.prototype.queryAll = function (selector) {
|
||||
return this.querySelectorAll(selector);
|
||||
};
|
||||
|
||||
Node.prototype.on = function (name, fn, options) {
|
||||
this.addEventListener(name, fn, options);
|
||||
};
|
||||
|
||||
Node.prototype.off = function (name, fn) {
|
||||
this.removeEventListener(name, fn);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue