fn

hideOthers

v0.0.5

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
declare function hideOthers(target: Element | Element[], parentNode?: Element, markerName?: string): Undo;

Parameters

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

Returns

UndoFunction that reverts the aria-hidden mutations