R
fn

hideOthers

v0.0.5tested

Marks 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

ParameterTypeDescription
targetElement | Element[]Element(s) to keep visible to AT
parentNode?Element | undefinedRoot to scan; defaults to `document.body`
markerName?stringData attribute used to ref-count our mutations

Returns

VoidFunctionFunction that reverts the aria-hidden mutations