GitXplorerGitXplorer
g

accessibilityjs

public
2170 stars
72 forks
5 issues

Commits

List of commits on branch main.
Verified
1b0731d5df2e188e0770deffcfdbf2d516ee91fd

Merge pull request #22 from github/check-hasattribute

mmislav committed 6 years ago
Unverified
bfd016bde12f996ab0c9d5f57ff0173388091eec

Check for `el.hasAttribute` before invoking

mmislav committed 6 years ago
Unverified
2395aab550f1803a3cfe4f1cd65d8fd083944261

1.1.1

mmislav committed 7 years ago
Unverified
281a60292a7b7a9bcc66c809f83b26ff2c19b555

Try `--no-sandbox` to see if it fixes CI

mmislav committed 7 years ago
Verified
53be80480d6feae69b05638e166c1bc569268cc4

Merge pull request #20 from github/iterating-classList

mmislav committed 7 years ago
Unverified
56932a3d1ae713e9eeb6afdb9a479bc9f4f313a8

Add extra tests for `inspect()` functionality

mmislav 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