Some people can’t:
- Use a mouse
- View a screen
- See low contrast text
- Hear dialogue or music
- Understand complex language
Some people need:
- Keyboard support
- Screen reader support
- High contrast text
- Captions and transcripts
- Plain language
Guess what: you can help!
…by making the Internet more accessible.
#A11y in Angular Apps
- Write meaningful HTML
- Enable the keyboard
- Handle focus
- Alert the user
- Coverage with tests
Meaningful HTML
Also
Meaningful HTML
Angular Material button in Chrome Accessibility Inspector
CSS changes button text to uppercase following the Material Design guidelines, which shows in the accessibility tree
Enable the keyboard
Handle focus
Alert the user
Intro to ARIA
https://www.w3.org/TR/wai-aria/
- Role: what is it?
role="button"
- State: what state is it in?
aria-checked="false"
- Property: what's the nature of it?
aria-haspopup="true"
aria-label="Close modal"
Accessibility with ngAria: Angular 1 documentation
ngAria
aria-checked code example and link to documentation https://docs.angularjs.org/api/ngAria
While ngAria was a worthwhile effort,
it only helps certain use cases.
Build accessibility into your workflow
~ with ~
Automated Testing
~ But ~
It’s no substitute for real user feedback
Testing for accessibility in:
Angular 1*
Angular 2
Directive-Specific
Unit Tests
Good for:
- Text alternatives / Labeling
- Keyboard operability
- ARIA attribute watching
Labeling unit test
Keyboard unit test
Integration/
End-to-End Tests
Good for:
- Color contrast
- Widget keyboard interrop
- Document-level rules
Get help with an API
Save yourself from:
- Label/name computation
- Incorrect ARIA usage
- Color contrast
- Data table markup
- Viewport/zooming probz
A11y test APIs: You’ve got options
- aXe
- Chrome A11y Developer Tools
- QUAIL
- Tenon
- WAVE
Demo App Template
End-to-End Test
Testing for accessibility in:
Angular 1
Angular 2*
Angular 2: Big differences
- Component-based
- TypeScript & ES6
- Property bindings
Medium article by Victor Savkin: Three Ways to Test Angular 2 Components
Test requirements for a11y
Test method |
Rendered |
Attached |
Unit |
Keyboard mechanics |
X |
X |
Labeling |
|
|
ARIA attributes |
~ |
~ |
End-to-end |
Color contrast |
X |
X |
Event handlers |
~ |
~ |
A11y API Audit |
X |
X |
Angular Material 2 Preview
Angular 2 Unit Test 1/2
Applying a text alternative with `aria-labelledby`
Angular 2 Unit Test 2/2
ARIA attribute watching
Angular 2 Keyboard Unit Tests
Angular 2 issue on Github: Creating fake event objects for testing components
Angular 2 Keyboard Test
End-to-End Testing in Angular 2
~ with ~
Protractor
End-to-End Keyboard Test
End-to-end Testing with aXe-core
Recap
- Accessibility is similar with all web frameworks.
- Unit tests provide a component accessibility contract.
- Use integration tests to redirect human resources.
- Use an API for extra a11y muscle.
- Prevent broken experiences from going out the door!
Thanks!