Closed mpnkhan closed 4 years ago
I suspect that for a switch based on a checkbox the requirement "required attribute: aria-checked" is automatically met because each checkbox has implicitly aria-checked=true or aria-checked=false (see https://w3c.github.io/html-aam/#el-input-checkbox).
So the error is probably caused by validators like axe and a ticket should be created there
This is not an issue with this document, but rather with validators as @JAWS-test mentions.
As ARIA in HTML already mentions:
Note: the HTML
checked
attribute may be used instead of thearia-checked
attribute formenuitemcheckbox
,option
orswitch
when used ontype=checkbox
.
If you are finding axe is throwing an error, then you can file a bug against that tool.
Nope, the bug is about the document https://w3c.github.io/html-aria/#index-aria-switch and https://www.w3.org/TR/wai-aria-1.1/#switch which says aria-checked is required attribute.
"The aria-checked attribute of a switch indicates whether the input is on (true) or off (false). The mixed value is invalid, and user agents MUST treat a mixed value as equivalent to false for this role.".
The document should explicitly state that aria-checked shouldn't be needed for checkbox elements.
Did i misunderstood?
Also filed https://github.com/dequelabs/axe-core/issues/2225 .
There are multiple ways to create a switch component, div, span, button. We can also use native element like checkbox with role=switch. Here is an example with switch component with checkboxes http://hcm-sample.surge.sh. W3C docs say aria-checked is a required attribute for switch role. Validators like axe throw an error even though the checked state is exposed by browsers and read by screen readers. aria-checked shouldn't be an required attribute for <input type="checkbox role="switch"">