-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(setup/teardown): add functions to setup and teardown axe-core internal data, deprecate axe._tree #2738
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WilcoFiers
previously requested changes
Jan 8, 2021
straker
changed the title
feat(setup/teardown): add functions to setup and teardown axe-core internal data
feat(setup/teardown): add functions to setup and teardown axe-core internal data, deprecate axe._tree
Jan 8, 2021
stephenmathieson
approved these changes
Jan 8, 2021
WilcoFiers
approved these changes
Jan 12, 2021
4 tasks
dbjorge
added a commit
to microsoft/accessibility-insights-web
that referenced
this pull request
May 19, 2021
#### Details `axe-core` 4.2.0 deprecated direct access to the internal `axe._tree` in favor of new `axe.setup` and `axe.teardown` APIs in dequelabs/axe-core#2738. This PR replaces our usage of the deprecated thing. The changes include: * Rewriting `getUniqueSelector` (and giving it unit tests, which it was missing) * Moving it from `ScannerUtils` to `AxeUtils` as part of its rewrite (it has no dependencies on the `Scanner`, and `AxeUtils` is where all the other axe-internal usages live) * As a result of this, updated `window-initializer` to drop its `ScannerUtils` dep * Creating a `withAxeSetup` wrapper for both `getUniqueSelector` and unit tests to use * Updating a bunch of unit tests (mostly of our custom checks/rules) to use `withAxeSetup` instead of manual `_tree` manipulation * Adding an end to end test page for custom widgets (tests for the custom widgets checks were impacted, so I wanted to make sure I exercised the checks during my manual validation of the PR) ##### Motivation There are a few reasons we want to do this. First, just as technical debt avoidance (avoiding dependency on a deprecated thing). Second, `axe.teardown()` does more cleanup than we were previously doing in `getUniqueSelector`; this avoids the possibility of `getUniqueSelector` leaking some invalid bit of cache data into a subsequent scan. Third, because `setup` contains an assertion that it hasn't already been called (eg, by axe itself while a scan is in progress), this improves our the behavior when `getUniqueSelector` is called while an axe scan is in progress. Practically speaking, this could happen if a user attempted to use the tab stops visualizer or the scoping feature's element selector while a scan is in progress. Previously, this would blindly overwrite axe's internal state while the scan was in progress, and was liable to cause silently incorrect scan results. With this change, the visualizer/selector operation will instead throw an error, and the scan will continue uninterrupted. I don't think it's super likely for users to hit this conflict in practice, but if a user did, I think a visualizer/selector failing and needing to be retried is vastly better than scan results being unpredictably inaccurate. ##### Context <!-- Are there any parts that you've intentionally left out-of-scope for a later PR to handle? --> <!-- Were there any alternative approaches you considered? What tradeoffs did you consider? --> #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [n/a] Addresses an existing issue: #0000 - [x] Ran `yarn fastpass` - [x] Added/updated relevant unit test(s) (and ran `yarn test`) - [x] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage` - [x] PR title *AND* final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See `CONTRIBUTING.md`. - [n/a] (UI changes only) Added screenshots/GIFs to description above - [n/a] (UI changes only) Verified usability with NVDA/JAWS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
New functions for setup up and teardown of axe-core internal data
axe._tree
and caches. As we're returning the tree now that is created, we are deprecatingaxe._tree
in favor of the return fromaxe.setup
Closes issue: #2570