Files
2026-08-01 01:09:58 +05:30

11 lines
401 B
TypeScript

export function collectRefs(root: ParentNode): Record<string, Element> {
const refs: Record<string, Element> = {};
if (root instanceof Element && root.hasAttribute("data-ref"))
refs[root.getAttribute("data-ref")!] = root;
root.querySelectorAll("[data-ref]").forEach((element) => {
const name = element.getAttribute("data-ref");
if (name) refs[name] = element;
});
return refs;
}