feat: support checkVisibility
API
#1365
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
I work on a test suite that runs exclusively in the browser so I was interested in exploring whether the new-ish
checkVisibility
API could help speed upByRole
queries. I did some not-super-scientific profiling and the key takeaways were:ByRole
queries are roughly ~2.3x slower thanByText
queriescheckVisibility
is reliably ~30% faster than the equivalentgetComputedStyle
checkcheckVisibility
has virtually no impact on the overall query time (put another way, visibility checking isn't the bottleneck in the browser - computing accessible name is)This should not get merged in its current state as it introduces code that doesn't run in this library's test environment. But wanted to at least start the discussion and see if my implementation is on the right track. Relatedly, JSDOM has a PR to add
checkVisibility
support, but I have no idea how likely it is to land.Related to #698
Related to #820
Related to eps1lon/dom-accessibility-api#1060
What: Add (environment-dependent) support for the
checkVisibility
API when calculating element visibility.Why: Use modern platform APIs, marginal perf improvement
How: Short-circuit
getComputedStyle
calls withcheckVisibility
callsChecklist:
docs site N/A