mirror of
https://github.com/github/accessibilityjs
synced 2026-07-21 03:33:43 +00:00
No description
- JavaScript 83.6%
- HTML 16.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| test | ||
| .babelrc | ||
| .eslintrc.json | ||
| .gitignore | ||
| .travis.yml | ||
| example.html | ||
| index.js | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| prettier.config.js | ||
| README.md | ||
accessibilityjs 
Client side accessibility error scanner.
Install
npm install accessibilityjs --save
Usage
import {scanForProblems} from 'accessibilityjs'
function logError(error) {
error.element.classList.add('accessibility-error')
error.element.addEventListener('click', function () {
alert(`${error.name}\n\n${error.message}`)
}, {once: true})
}
document.addEventListener('DOMContentLoaded', function() {
scanForProblems(document, logError)
})
List of errors:
ImageWithoutAltAttributeErrorElementWithoutLabelErrorLinkWithoutLabelOrRoleErrorLabelMissingControlErrorInputMissingLabelErrorButtonWithoutLabelErrorARIAAttributeMissingError
Scenario
In GitHub we use this script to scan for inaccessible elements in development and production staff mode. We style the elements with red borders in the logError function passed in, and add a click handler explaining the reasons.
Browser support
- Chrome
- Firefox
- Safari 6+
- Internet Explorer 9+
- Microsoft Edge
Internet Explorer and Edge require a polyfill for closest.
Development
> npm install
> npm test
> npm run example

