Skip to content

🪵 Accessible HTML element removal

License

Notifications You must be signed in to change notification settings

ubermanu/kawarimi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!'