Client side accessibility error scanner.
Перейти к файлу
Mislav Marohnić 2395aab550 1.1.1 2018-03-09 17:02:00 +01:00
test Try `--no-sandbox` to see if it fixes CI 2018-03-09 16:57:58 +01:00
.babelrc Change window global 2017-10-06 10:11:27 +08:00
.eslintrc.json Stop linting prettier.conf.js so we dont need node env 2017-11-08 15:29:36 +08:00
.gitignore Add babel for es2015 2017-10-06 09:30:42 +08:00
.travis.yml Add travis.yml 2017-11-06 11:17:26 +08:00
LICENSE Add license text 2017-06-26 23:42:08 +08:00
README.md Add build status badge 2017-11-14 16:35:33 +08:00
example.html Update `example` - log all errors 2017-10-28 00:17:17 +02:00
index.js Avoid iterating over `classList` using `for..of` 2018-03-09 15:38:11 +01:00
package-lock.json 1.1.1 2018-03-09 17:02:00 +01:00
package.json 1.1.1 2018-03-09 17:02:00 +01:00
prettier.config.js Use eslint-plugin-github 2017-11-06 11:02:59 +08:00

README.md

accessibilityjs build status

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:

  • ImageWithoutAltAttributeError
  • ElementWithoutLabelError
  • LinkWithoutLabelOrRoleError
  • LabelMissingControlError
  • InputMissingLabelError
  • ButtonWithoutLabelError
  • ARIAAttributeMissingError

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.

Red borders are added to offending elements example

An alert pops up on clicking the elements

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