Skip to content

False positive: aria-checked should not be flagged as missing on an <input type="checkbox" role="switch"> #77

@unekinn

Description

@unekinn

Describe the bug

ARC toolkit incorrectly flags an error, "Missing required aria-attribute", for aria-checked on <input type="checkbox" role="switch">

While the WAI-ARIA specification for role="switch" does list aria-checked under required states and properties, this must be read in the context of the rest of the document. §5.2.2 Required States and Properties states:

A host language attribute with the appropriate implicit WAI-ARIA semantic fulfills this requirement.

In this context, HTML is our "host language", and checked is a "host language attribute". Furthermore, §8.4 Implicit WAI-ARIA Semantics states that:

[…] there are many situations in which WAI-ARIA semantics are redundant with host language semantics. […] Features with implicit WAI-ARIA semantics satisfy WAI-ARIA structural requirements such as required owned elements, required states and properties, etc. and do not require explicit WAI-ARIA semantics to be provided. […] For example, if an element with the functionality already exists, such as a checkbox or radio button, use the native semantics of the host language.

(emphasis mine)

Since the switch role inherits from checkbox, the implicit aria-checked semantics provided by the native checked state on <input type="checkbox"> carry over when role="switch" is applied.

To Reproduce

  1. Go to ARIA APG: Switch Example Using HTML Checkbox Input
  2. Run tests on the page in ARC Toolkit
  3. See that errors are flagged for the switches in the example (under "Accessibility Preferences")

Expected behavior

There should be no errors flagged, as <input type="checkbox"> inherently exposes its checked state to the accessibility tree.

Screenshots

Screenshot showing two instances of 'Missing required ARIA attribute' with description: 'The element is missing required aria-checked attribute(s)'

Version information

  • Browser and version: Chrome 149.0.7827.54 (Official Build) (arm64)
  • ARC Toolkit version: 5.7.10

Additional context

The accessibility tree in Chrome DevTools confirms that the checked state is correctly exposed without an explicit aria-checked attribute.

Initially, when the switch is off:

Role: switch
...
Checked: false

After turning the switch on:

Role: switch
...
Checked: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions