Client side accessibility error scanner.
Перейти к файлу
Mu-An ✌️ Chiou 05956b2325 1.1.0 2017-11-14 16:37:47 +08:00
test Prettify 2017-11-14 16:31:53 +08: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 Lint fixes: change function style 2017-11-13 14:40:40 +01:00
package-lock.json 1.1.0 2017-11-14 16:37:47 +08:00
package.json 1.1.0 2017-11-14 16:37:47 +08: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