Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

makeup-focusables

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makeup-focusables

Returns an array of all focusable descendants of the given element

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
121
decreased by-74.31%
Maintainers
5
Weekly downloads
 
Created
Source

makeup-focusables

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

Experimental

This CommonJS 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)
  • callback: if set, will call focusables after requestAnimationFrame and will pass the list of focusables in a callback method

Custom Events

  • None

Dependencies

  • None

Polyfills

  • None

Keywords

FAQs

Package last updated on 10 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc