Open DavidSouther opened 1 year ago
Confirmed this is a bug. Thanks for letting us know.
per the provided demo code snippet though:
<label>
<input
type="checkbox"
role="switch"
name="switch"
checked="checked"
aria-checked="false"
/>
Switch 1
</label>
there should at least be a failure called out for the use of checked
and aria-checked=false
, since those contradict each other and the native HTML attribute is supposed to take precedent over the aria equivalent.
That... is an excellent observation haha! But the message doesn't say that. Maybe there's two bugs here?
Note: I think this relates to https://github.com/dequelabs/axe-core/issues/2225 aria-checked shouldn't be a mandatory attribute for element with role=switch if the element is created with checkbox. #2225
Axe Linter in VS Code finds 2 problems with this: `
` axe-linter (aria-required-attr): Ensures elements with ARIA roles have all required ARIA attributes axe-linter (aria-allowed-role): Ensures role attribute has an appropriate value for the element
Adding aria-checked="false" removes the aria-required-attr but aria-allowed-role remains.
`
` Neither error should be showing up here with the original code.
Adding aria-checked="false" removes the aria-required-attr but aria-allowed-role remains.
<input type="checkbox" role="switch" aria-checked="false" id="marketingCookies" checked>
Neither error should be showing up here with the original code.
which is exactly why the linter needs to be updated to not call out the error, so that invalid code like this isn't written to suppress the issue.
Just a heads up on this ticket. This should be fixed in the next release of axe-linter, which should be happening in the next few weeks.
Product
axe Linter
Product Version
v4.4.2
Latest Version
Issue Description
Expectation
should (I believe) be a valid aria configuration for a switch checkbox.
Actual
This code is flagged with
How to Reproduce
demo.html:
Additional context