mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 22:50:07 +01:00
27 lines
593 B
JavaScript
27 lines
593 B
JavaScript
|
const $ = function(selector) {
|
||
|
return document.querySelector(selector);
|
||
|
};
|
||
|
|
||
|
const $$ = function(selector) {
|
||
|
return document.querySelectorAll(selector) || [];
|
||
|
};
|
||
|
|
||
|
const makeEl = function(html) {
|
||
|
const template = document.createElement('template');
|
||
|
|
||
|
template.innerHTML = html.trim();
|
||
|
|
||
|
return template.content.firstChild;
|
||
|
};
|
||
|
|
||
|
const escape = function(unsafe) {
|
||
|
return unsafe
|
||
|
.replace(/&/g, "&")
|
||
|
.replace(/</g, "<")
|
||
|
.replace(/>/g, ">")
|
||
|
.replace(/"/g, """)
|
||
|
.replace(/'/g, "'");
|
||
|
}
|
||
|
|
||
|
|
||
|
export { $, $$, makeEl, escape };
|