export function collectRefs(root: ParentNode): Record { const refs: Record = {}; 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; }