kawarimi
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Kawarimi

CI

Small function that removes an element but keeps the focus at the correct position.

When the element is removed, the focus is moved to the decoy.
Once the decoy loses focus, the decoy is removed.

Install

npm install kawarimi

Usage

import kawarimiNoJutsu from 'kawarimi'

const target = document.querySelector('#alert-message')
kawarimiNoJutsu(target)

You can also indicate that the element has been removed:

const target = document.querySelector('#alert-message')
const decoy = kawarimiNoJutsu(target)

decoy.setAttribute('aria-live', 'polite')
decoy.textContent = 'Kawarimi no jutsu!'

Package Sidebar

Install

npm i kawarimi

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

5.65 kB

Total Files

7

Last publish

Collaborators

  • ubermanu