GitXplorerGitXplorer
g

accessibilityjs

public
2170 stars
72 forks
5 issues

Commits

List of commits on branch main.
Unverified
6ab5db75f7dd1eae336ec6367aeb584202896bc1

Avoid iterating over `classList` using `for..of`

mmislav committed 7 years ago
Unverified
05956b23259fe9d1faed2b231e81c4d474b75797

1.1.0

mmuan committed 7 years ago
Unverified
6190e57107058afe47266816252443ef686d3177

Add build status badge

mmuan committed 7 years ago
Unverified
a3d2274766b889ced2b54f3f861c06e04b5f26bf

Prettify

mmuan committed 7 years ago
Unverified
f0afd57c6ae045a45617816fcb23284e17a1ffec

Merge branch 'easingthemes-feature/return-all-errors'

mmuan committed 7 years ago
Unverified
8b77d67c69f5ea5f202a3364f18ca54414e8aa53

Lint fixes: change function style

eeasingthemes 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