GitXplorerGitXplorer
g

accessibilityjs

public
2170 stars
72 forks
5 issues

Commits

List of commits on branch main.
Unverified
652e3d69e82ff4cb5b9145c9d047d492738a7727

Merge branch 'master' into feature/return-all-errors

eeasingthemes committed 7 years ago
Verified
01ccfee2b4fbca5957345322bfcbbd3a60f817ef

Merge pull request #1 from github/master

eeasingthemes committed 7 years ago
Verified
49e9aac1666ed9f90ddcf4092e7f23079144ad5a

Merge pull request #16 from github/eslint

mmuan committed 7 years ago
Unverified
32337b7558b8ff50e559736d66ab43427044eda2

Stop linting prettier.conf.js so we dont need node env

mmuan committed 7 years ago
Unverified
d0ea7817e4397bc2483fbcc94722cdb7c0f45384

Add back previous envs

mmuan committed 7 years ago
Unverified
39d3ccae5b1878ee7db8790ebe0094d3ffe0c80f

Merge branch 'master' into eslint

mmuan committed 7 years ago

README

The README file for this repository.

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