Utilities

Details

Members


<private, static> _focusStorage :HTMLElement

Description

Used to keep track of focus. Defaults to body.

Details
HTMLElement

Methods


<static> exports.ariaHidden( element, flag )

Description

Set the aria-hidden state to an element.

Parameters
Name Type Description
element HTMLElement

DOM node where we set state.

flag boolean

Whether the DOM node should be hidden.


<static> exports.inert( element, flag )

Description

Apply inert to an element.

Parameters
Name Type Description
element HTMLElement

DOM node where we set state.

flag boolean

Whether the DOM node should have inert.

Details

<static> exports.saveFocus()

Description

Save the currently focused element. Useful if you want to save and restore focus to a specific element after e.g an alert or dialog.

Details

<static> exports.restoreFocus( [ waitAFrame ] ) → {HTMLElement}

Description

Restore the focus to an element.

Parameters
Name Type Attributes Default Description
waitAFrame boolean <optional>
false

Whether we should wait a frame before restoring focus to an element. Useful when dealing with toggling elements.

Returns
  • Returns the saved element as a convenience.
Details

<static> exports.focusable( element, shouldBeFocusable )

Description

Set an element to be focusable or not.

Parameters
Name Type Description
element HTMLElement
shouldBeFocusable boolean

Whether the element is allowed focus or not.

Details

<static> exports.isHidden( element ) → {boolean}

Description

Whether the given element is focusable or not.

Parameters
Name Type Description
element HTMLElement
Returns
Details