style: format static/dedupe.ts

This commit is contained in:
2026-06-21 02:04:30 +02:00
committed by Milas Holsting
parent a1582226ef
commit 8cd9ac94e9

View File

@@ -19,7 +19,7 @@ export const dedupeByID = <T>(items: T[], idForItem: (item: T) => string | undef
export const dedupeWithin = (root: ParentNode): void => { export const dedupeWithin = (root: ParentNode): void => {
const elements = root.querySelectorAll<HTMLElement>(":scope > [data-id]"); const elements = root.querySelectorAll<HTMLElement>(":scope > [data-id]");
const uniqueElements = new Set(dedupeByID(Array.from(elements), (item) => item.dataset.id)); const uniqueElements = new Set(dedupeByID([...elements], (item) => item.dataset.id));
elements.forEach((item) => { elements.forEach((item) => {
if (!uniqueElements.has(item)) { if (!uniqueElements.has(item)) {
@@ -69,6 +69,12 @@ const dedupeSwapTarget = (target: EventTarget | null): void => {
}); });
}; };
onReady(() => dedupe()); onReady(() => {
window.addEventListener("load", () => dedupe()); dedupe();
onHtmxLoad((root) => dedupeSwapTarget(root)); });
window.addEventListener("load", () => {
dedupe();
});
onHtmxLoad((root) => {
dedupeSwapTarget(root);
});