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;
}
