Skip to content
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

Update cssParser to allow more complex selectors #1493

Closed
straker opened this issue Apr 11, 2019 · 0 comments · Fixed by #1494
Closed

Update cssParser to allow more complex selectors #1493

straker opened this issue Apr 11, 2019 · 0 comments · Fixed by #1494
Labels
core Issues in the core code (lib/core) feat New feature or enhancement

Comments

@straker
Copy link
Contributor

straker commented Apr 11, 2019

Currently the imported cssSelectorParser is only registered to handle the nesting operator >, but our querySelectorAll code can handle more complex selectors and pseudo selectors. This means that even though we can handle it, trying to run axe.utils.querySelectorAll(virtualNode, 'a[href^="#"]') throws an error in the cssSelectorParser as it doesn't expect the ^.

We should update the registration of the cssSelectorParser and allow the :not pseudo selector as well as the matching selectors ^=, $=, ~=, |=, and *=.

Expectation: axe.utils.querySelectorAll(virtualNode, 'a[href^="#"]') should return all hrefs that don't start with #

Actual: cssSelectorParser throws an error

Motivation: Can reduce matches logic by being able to filter out results in the selector, as well as being able to use more complex selectors

axe-core version: 3.2.2
WilcoFiers pushed a commit that referenced this issue Apr 12, 2019
Updates the CSS Selector Parser to allow more complex selectors: `:not`, `^=`, `$=`, and `*=`. Also update docs to describe what selectors we support.

Closes: #1493 

## Reviewer checks

**Required fields, to be filled out by PR reviewer(s)**
- [x] Follows the commit message policy, appropriate for next version
- [x] Has documentation updated, a DU ticket, or requires no documentation change
- [x] Includes new tests, or was unnecessary
- [x] Code is reviewed for security by: @WilcoFiers
@WilcoFiers WilcoFiers added this to the Axe-core 3.3 milestone May 1, 2019
@WilcoFiers WilcoFiers added core Issues in the core code (lib/core) feat New feature or enhancement labels Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues in the core code (lib/core) feat New feature or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants