JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 185
  • Score
    100M100P100Q102602F
  • License MIT

Returns an array of all focusable descendants of the given element

Package Exports

  • makeup-focusables

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (makeup-focusables) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

makeup-focusables

Build Status Coverage Status Dependency status devDependency status

Returns an array of all focusable descendants of the given element.

A vanilla JavaScript port of jquery-focusable.

Experimental

This module is still in an experimental state, until it reaches v1.0.0 you must consider all minor releases as breaking changes. Patch releases may introduce new features, but will be backwards compatible.

Install

// via npm
npm install makeup-focusables

// via yarn
yarn add makeup-focusables

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>
// require the module
const focusables = require('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)

Custom Events

  • None

Dependencies

  • None

Polyfills

  • None

Development

  • npm start
  • npm test
  • npm run lint
  • npm run fix
  • npm run build
  • npm run clean

Test Reports

Each test run will generate the following reports:

  • /reports/coverage contains Istanbul code coverage report
  • /reports/html contains HTML test report

CI Build

https://travis-ci.org/makeup-js/makeup-focusables

Code Coverage

https://coveralls.io/github/makeup-js/makeup-focusables