Skip to content

given a dom tree, return an approximation of the text which is visible to a screen reader

Notifications You must be signed in to change notification settings

wyattdanger/computed-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis CI

computedText(node) returns an approximation of the text which would be read aloud by a screen reader.

test('Contrived example', () => {
  document.body.innerHTML = `
    <h1>Hello World</h1>
    <div style="display: none">I am hidden</div>
    <img src="foo.jpg" alt="Bar" />
  `;
  expect(computedText(document.body)).toBe('Hello World Bar');
});

Local development:

npm install
npm run test

Use cases:

  • Verify that text which should be visible/invisible to a screen reader is marked up appropriately
  • Run as an approval test in CI to detect changes in the text representation of components

Heavily based on the findTextAlternatives method in GoogleChrome/accessibility-developer-tools

About

given a dom tree, return an approximation of the text which is visible to a screen reader

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published