dequelabs / dequelabs/axe-core
Allow rule "selector" property to be a matcher object
- Dominant language
- JavaScript
- Stars
- 7.5k
- Forks
- 933
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 17
Description
Currently axe-core rules can only take CSS selectors in the selector. This is somewhat limiting, and is the cause of us writing a whole bunch of matchers that often do a very similar thing.
### Proposal
Allow objects as a selector, which will be passed to [`axe.commons.matches()`](https://github.com/dequelabs/axe-core/blob/develop/lib/commons/matches/index.js). This gives us a bunch of new capability, most importantly, letting us deal with fallback rules:
```html
```
```json
{
"id": "svg-img-has-alt",
"selector": {
"nodeName": "svg",
"semanticRole": "img"
}
}
```
Another common pattern it lets us ditch is this `input:not([type="hidden"]):not([type="image"]):not(...` type selector, which works if you're only interested in one thing, but gets quite unwieldy when it gets more complex.
Contributor guide
Assessment
This issue has not been assessed yet.