From 7aa2d4183fce6ef8aff9ad8fc40dc8b0e03497c7 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 25 Dec 2024 19:32:52 +0300 Subject: [PATCH] code cosmetics: rename toggleClasses --- src/js/dom-init.js | 4 ++-- src/js/dom.js | 16 ++++++++-------- src/manage/updater-ui.js | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/js/dom-init.js b/src/js/dom-init.js index 814441e5de..af84705859 100644 --- a/src/js/dom-init.js +++ b/src/js/dom-init.js @@ -1,4 +1,4 @@ -import {$, $toggleClasses, dom, mqCompact} from './dom'; +import {$, dom, mqCompact, toggleClasses} from './dom'; import {waitForSelector} from './dom-util'; import * as prefs from './prefs'; import {FIREFOX, MOBILE, OPERA, VIVALDI, WINDOWS} from './ua'; @@ -52,7 +52,7 @@ prefs.ready.then(() => { if (mqCompact) { const toggleCompact = mq => { mq = mq.matches; - $toggleClasses($.root, { + toggleClasses($.root, { 'compact-layout': mq, 'normal-layout': !mq, }); diff --git a/src/js/dom.js b/src/js/dom.js index f618acd1d4..7d802177f2 100644 --- a/src/js/dom.js +++ b/src/js/dom.js @@ -177,6 +177,13 @@ export function $detach(el, state = true) { return state; } +/** Moves child nodes to a new document fragment */ +export function $toFragment(el) { + const bin = document.createDocumentFragment(); + bin.append(...el.childNodes); + return bin; +} + /** * construct a new className: * 1. add a class if value is truthy @@ -185,7 +192,7 @@ export function $detach(el, state = true) { * @param {HTMLElement} el * @param {object} newClasses */ -export function $toggleClasses(el, newClasses) { +export function toggleClasses(el, newClasses) { const list = new Set(); for (const c of el.classList) list.add(c); for (const c in newClasses) if (newClasses[c]) list.add(c); else list.delete(c); @@ -193,13 +200,6 @@ export function $toggleClasses(el, newClasses) { if (el.className !== res) el.className = res; } -/** Moves child nodes to a new document fragment */ -export function $toFragment(el) { - const bin = document.createDocumentFragment(); - bin.append(...el.childNodes); - return bin; -} - export function toggleDataset(el, prop, state) { if (!el) return; const wasEnabled = el.dataset[prop] != null; // avoids mutating DOM unnecessarily diff --git a/src/manage/updater-ui.js b/src/manage/updater-ui.js index 1b5c262a56..a15b6034f7 100644 --- a/src/manage/updater-ui.js +++ b/src/manage/updater-ui.js @@ -1,4 +1,4 @@ -import {$, $$, $create, $detach, $toggleClasses} from '@/js/dom'; +import {$, $$, $create, $detach, toggleClasses} from '@/js/dom'; import {messageBox, scrollElementIntoView} from '@/js/dom-util'; import {template} from '@/js/localization'; import {API} from '@/js/msg'; @@ -192,7 +192,7 @@ function reportUpdateState({updated, style, error, STATES}) { } } - $toggleClasses(entry, newClasses); + toggleClasses(entry, newClasses); if (filtersSelector.hide && isCheckAll) { filterAndAppend({entry}).then(updateStripes);