Skip to content

Commit

Permalink
Use dataset instead of attribute functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Usbac committed Apr 6, 2024
1 parent 8e3a5fe commit 19247f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/views/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions public/assets/css/admin/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ textarea.code {
display: none;
}

#snackbar[show] {
#snackbar[data-show] {
top: 20px;
}

Expand Down Expand Up @@ -1158,7 +1158,7 @@ textarea.code {
overflow: hidden;
}

.dropdown-menu[active] {
.dropdown-menu[data-active] {
display: flex;
}

Expand Down
8 changes: 4 additions & 4 deletions public/assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 19247f8

Please sign in to comment.