fn
hideOthers
v0.0.5Marks 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
| Parameter | Type | Description |
|---|---|---|
target | Element | Element[] | Element(s) to keep visible to AT |
parentNode? | Element | Root to scan; defaults to document.body |
markerName? | string | Data attribute used to ref-count our mutations |
Returns
UndoFunction that reverts the aria-hidden mutations