Skip to content

add javascript contrast watcher#5347

Draft
Bubballoo3 wants to merge 4 commits intomasterfrom
add-contrast-test
Draft

add javascript contrast watcher#5347
Bubballoo3 wants to merge 4 commits intomasterfrom
add-contrast-test

Conversation

@Bubballoo3
Copy link
Copy Markdown
Contributor

In draft while I work out the kinks, but this seems to be the best approach for checking contrast without adding dependencies.

The basic premise is that we attach this snippet of javascript to every 'visit' call, ensuring that it runs on all tests without needing modification. From there, the javascript

  • reads every element, checking if the element is valid, visible, and contains text directly (not a child with text)
  • reads the computed styles, deferring to parents when it encounters a transparent background
  • raises a javascript error when a violating element is found, which fails the test and shows the javascript error (with info about the offending element).

I have only tested this in limited contexts and will no doubt encounter edge cases when it is run with all the tests. However I think the potential benefits are real and that in the long run this will be worth developing and maintaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants