From 74a8e3babfc803aca93c0fdbe29ef5994aaa096f Mon Sep 17 00:00:00 2001 From: Maksim Kostromin Date: Sun, 25 Oct 2026 22:55:50 -0400 Subject: [PATCH] refactor(ui): array.from instead of spread over node lists --- src/main.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 45700cd..60479cc 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -877,7 +877,7 @@ function rerenderKeepingFilterFocus(): void { render(); suppressTableAnimation = false; if (key === undefined) return; - const next: any = [...el.tableHead.querySelectorAll('input[data-filter-col]')].find((node: any) => node.dataset.filterCol === key && node.dataset.filterScope === scope); + const next: any = Array.from(el.tableHead.querySelectorAll('input[data-filter-col]')).find((node: any) => node.dataset.filterCol === key && node.dataset.filterScope === scope); if (next) { next.focus(); try { next.setSelectionRange(caret, caret); } catch { /* not a text input */ } } }); } @@ -1208,7 +1208,7 @@ function createDropdown(cfg: DropdownConfig): Dropdown { } function paintActive(scroll: boolean): void { - const rows: any[] = [...list.querySelectorAll('.dd-opt')]; + const rows: any[] = Array.from(list.querySelectorAll('.dd-opt')); let activeEl: any = null; rows.forEach(row => { const on = row.dataset.id === activeId; @@ -1306,7 +1306,7 @@ function createDropdown(cfg: DropdownConfig): Dropdown { trigger.setAttribute('aria-expanded', 'true'); input.focus({ preventScroll: true }); input.setSelectionRange(input.value.length, input.value.length); - const row: any = [...list.querySelectorAll('.dd-opt')].find((r: any) => r.dataset.id === activeId); + const row: any = Array.from(list.querySelectorAll('.dd-opt')).find((r: any) => r.dataset.id === activeId); if (row) list.scrollTop = Math.max(0, row.offsetTop - list.offsetTop - list.clientHeight / 3); paintActive(false); } @@ -1401,14 +1401,14 @@ function createDropdown(cfg: DropdownConfig): Dropdown { // The panel lives at the end of , so Tab at its edges hands focus back to the page order around the trigger. panel.addEventListener('keydown', (event: any) => { if (event.key !== 'Tab') return; - const focusable = [...panel.querySelectorAll('input, button')].filter((node: any) => node.tabIndex >= 0 && node.offsetParent !== null); + const focusable = Array.from(panel.querySelectorAll('input, button')).filter((node: any) => node.tabIndex >= 0 && node.offsetParent !== null); if (!focusable.length) return; const edge = event.shiftKey ? focusable[0] : focusable[focusable.length - 1]; if (event.target !== edge) return; event.preventDefault(); close(); if (event.shiftKey) { trigger.focus({ preventScroll: true }); return; } - const page = [...document.querySelectorAll('a[href], button, input, select, textarea, [tabindex]')] + const page = Array.from(document.querySelectorAll('a[href], button, input, select, textarea, [tabindex]')) .filter((node: any) => !panel.contains(node) && node.tabIndex >= 0 && !node.disabled && (node.offsetParent !== null || node === trigger)); const next: any = page[page.indexOf(trigger) + 1]; if (next) next.focus(); @@ -1444,7 +1444,7 @@ function loadHiddenColumns(): void { function persistHiddenColumns(): void { try { - localStorage.setItem(COLUMN_VISIBILITY_KEY, JSON.stringify([...hiddenColumns])); + localStorage.setItem(COLUMN_VISIBILITY_KEY, JSON.stringify(Array.from(hiddenColumns))); } catch { // Storage is blocked: the choice lasts for this page only. } @@ -1541,7 +1541,7 @@ function loadHiddenCategories(): void { function persistHiddenCategories(): void { try { - localStorage.setItem(HIDDEN_CATEGORIES_KEY, JSON.stringify([...hiddenCategories])); + localStorage.setItem(HIDDEN_CATEGORIES_KEY, JSON.stringify(Array.from(hiddenCategories))); } catch { // Storage is blocked: the choice lasts for this page only. }