style: format static/dedupe.ts
This commit is contained in:
@@ -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);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user