Socket
Socket
Sign inDemoInstall

a11y-focus-scope

Package Overview
Dependencies
2
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    a11y-focus-scope

Accessibility util for scoping focus to an element.


Version published
Weekly downloads
3.2K
decreased by-3.27%
Maintainers
1
Install size
145 kB
Created
Weekly downloads
 

Readme

Source

a11y-focus-scope

Accessibility util for scoping focus to an element.

Installation

$ npm install --save a11y-focus-scope

Usage

import {scopeFocus, unscopeFocus} from 'a11y-focus-scope';

document.body.innerHTML = `
  <button id="outer-button">Outer Button</button>

  <div id="container">
    <button id="inner-button">Inner Button</button>
  </div>
`;

var container = document.getElementById('container');
var innerButton = document.getElementById('inner-button');
var outerButton = document.getElementById('outer-button');

scopeFocus(container);
// document.activeElement === container;

innerButton.focus();
// document.activeElement === innerButton;

outerButton.focus();
// document.activeElement === container;

unscopeFocus();
outerButton.focus();
// document.activeElement === outerButton;

Keywords

FAQs

Last updated on 09 Nov 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc