From 19247f8c6ae7f04a1efeb3786cea225eef6d0178 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Sat, 6 Apr 2024 14:43:08 +0200 Subject: [PATCH] Use dataset instead of attribute functions --- app/views/admin/settings.php | 4 ++-- public/assets/css/admin/main.css | 4 ++-- public/assets/js/admin.js | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/admin/settings.php b/app/views/admin/settings.php index c19061e..c5a750d 100755 --- a/app/views/admin/settings.php +++ b/app/views/admin/settings.php @@ -273,8 +273,8 @@ function update() { ? 'initial' : 'none'); document.querySelectorAll('.tabs > a').forEach(el => el.getAttribute('href') == location.hash - ? el.setAttribute('data-checked', true) - : el.removeAttribute('data-checked')); + ? el.dataset.checked = true + : delete el.dataset.checked); }); window.addEventListener('load', () => { diff --git a/public/assets/css/admin/main.css b/public/assets/css/admin/main.css index e996908..05751e2 100755 --- a/public/assets/css/admin/main.css +++ b/public/assets/css/admin/main.css @@ -706,7 +706,7 @@ textarea.code { display: none; } -#snackbar[show] { +#snackbar[data-show] { top: 20px; } @@ -1158,7 +1158,7 @@ textarea.code { overflow: hidden; } -.dropdown-menu[active] { +.dropdown-menu[data-active] { display: flex; } diff --git a/public/assets/js/admin.js b/public/assets/js/admin.js index 2781d28..6159b0e 100755 --- a/public/assets/js/admin.js +++ b/public/assets/js/admin.js @@ -48,14 +48,14 @@ class Snackbar { } get('#snackbar > span').innerHTML = msg; - snackbar.setAttribute('show', true); + snackbar.dataset.show = true; this.#timeout = setTimeout(() => this.hide(), 5000); } static hide() { let snackbar = get('#snackbar'); clearTimeout(this.#timeout); - snackbar.removeAttribute('show'); + delete snackbar.dataset.show; setTimeout(() => snackbar.classList.remove('error'), 200); } } @@ -285,7 +285,7 @@ class Dropdown { this.#active_dropdown = dropdown; if (this.#active_dropdown) { - this.#active_dropdown.setAttribute('active', true); + this.#active_dropdown.dataset.active = true; this.#active_dropdown.original_btn = dropdown_btn; document.body.appendChild(this.#active_dropdown); updateActiveDropdown(); @@ -295,7 +295,7 @@ class Dropdown { static close() { if (this.#active_dropdown) { - this.#active_dropdown.removeAttribute('active'); + delete this.#active_dropdown.dataset.active; this.#active_dropdown.original_btn.appendChild(this.#active_dropdown); } }