fn
hideOthers
v0.0.5testedMarks every sibling of `target` (within `parentNode`, defaulting to `document.body`) as `aria-hidden="true"` so assistive technologies skip them. `aria-live` regions and `<script>` elements are preserved. Returns an undo function that restores the previous state; calls stack (ref-counted) across multiple layers. Port of the `aria-hidden` npm package, kept dependency-free.
Signature
ts
export function hideOthers(target: Element | Element[], parentNode?: Element, markerName = DEFAULT_MARKER): Undo{ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
target | Element | Element[] | Element(s) to keep visible to AT |
parentNode? | Element | undefined | Root to scan; defaults to `document.body` |
markerName? | string | Data attribute used to ref-count our mutations |
Returns
VoidFunctionFunction that reverts the aria-hidden mutations