/** * A container that keeps only part of its content mounted — `ModalSectionWrapper` mounts just the * active section — but can mount the rest on request, so a validation scan can find an error that * sits in a part the user is not looking at. */ export interface ErrorProbeHost { /** The host's root element; a scan probes only the hosts inside the scope it scans. */ getErrorProbeRoot: () => Element | null; /** * Mounts every part, the inactive ones hidden. Probes nest: each call is paired with one * `endErrorProbe()`, and everything stays mounted until the last one ends. */ beginErrorProbe: () => void; /** Ends one `beginErrorProbe()`. Once none is open, only the active part stays mounted. */ endErrorProbe: () => void; } /** * The mounted {@link ErrorProbeHost}s, so `ScrollUtils` can reach them from a plain DOM scope. */ export default class ErrorProbeRegistry { private static readonly _hosts = new Set(); static register(host: ErrorProbeHost): void { ErrorProbeRegistry._hosts.add(host); } static unregister(host: ErrorProbeHost): void { ErrorProbeRegistry._hosts.delete(host); } /** The registered hosts whose root lies inside `scope`. */ static within(scope: Element): ErrorProbeHost[] { return Array.from(ErrorProbeRegistry._hosts).filter((host) => { const root = host.getErrorProbeRoot(); return root != null && scope.contains(root); }); } }