accessibilityjs

Client side accessibility error scanner.

  • Owner: github/accessibilityjs
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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

Overview

Name With Ownergithub/accessibilityjs
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 2)
Platform
License:MIT License
Release Count5
Last Release Namev1.1.1 (Posted on 2018-03-09 17:02:00)
First Release Name1.0.1 (Posted on )
Created At2017-06-22 12:41:18
Pushed At2020-08-03 15:47:33
Last Commit At
Stargazers Count2.2k
Watchers Count38
Fork Count72
Commits Count101
Has Issues Enabled
Issues Count4
Issue Open Count1
Pull Requests Count13
Pull Requests Open Count4
Pull Requests Close Count3
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private
To the top