0.4.3 • Published 4 months ago

makeup-focusables v0.4.3

Weekly downloads
97
License
MIT
Repository
-
Last release
4 months ago

makeup-focusables

Returns an array of all focusable descendants of the given element, excluding elements that are hidden or children of hidden elements.

Experimental

This module is still in an experimental state, until it reaches v1 you must consider all minor releases as breaking changes.

Example

Markup:

<div class="widget">
  <h2 tabindex="-1">Widget Title</h2>
  <p>Widget Text</p>
  <button type="button">Widget Button</button>
  <a href="#">Widget Link</a>
</div>
import focusables from "makeup-focusables";

// get element reference
const widgetEl = document.querySelector(".widget");

// get array of all focusable elements (keyboard and programmatic)
const allItems = focusables(widgetEl);

console.log(allItems.length); // outputs: 3

// get array of only keyboard focusable elements
const keyboardItems = focusables(widgetEl, true);

console.log(keyboardItems.length); // outputs: 2

Parameters

  • el: the element to search (default: undefined)
  • keyboardOnly: return only elements focusable in sequential keyboard navigation (default: false)
  • callback: if set, will call focusables after requestAnimationFrame and will pass the list of focusables in a callback method

Custom Events

  • None
0.4.3

4 months ago

0.4.1

5 months ago

0.4.2

5 months ago

0.3.2

8 months ago

0.4.0

8 months ago

0.3.1

2 years ago

0.3.0

3 years ago

0.2.0

4 years ago

0.1.0

5 years ago

0.0.5

5 years ago

0.0.4

6 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago