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 ARIA state or property has valid value rule to current writing style #1433

Closed
wants to merge 17 commits into from
Closed
1 change: 1 addition & 0 deletions __tests__/spelling-ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# Domain-specific words, Definitions & other allowed terms
- ABNF
- uri
- URI
- UA/AT
- WCAG
Expand Down
113 changes: 48 additions & 65 deletions _rules/aria-state-or-property-valid-value-6a7281.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,19 @@ acknowledgments:

## Applicability

Any [WAI-ARIA 1.1 state or property](https://www.w3.org/TR/wai-aria-1.1/#state_prop_def) that is not empty (""), and that is specified on an HTML or SVG element.
The rule applies to any [WAI-ARIA 1.1 state or property][] that is not empty (`""`), and is specified on an HTML or SVG element.

## Expectation

Each test target has a valid value according to its [WAI-ARIA 1.1 value type](https://www.w3.org/TR/wai-aria-1.1/#propcharacteristic_value).

For value types `ID Reference` and `ID Reference List` for [WAI-ARIA required properties](https://www.w3.org/TR/wai-aria-1.1/#requiredState) at least one of the elements with the given ids exists in the same [document tree](https://dom.spec.whatwg.org/#document-trees) or [shadow tree](https://dom.spec.whatwg.org/#shadow-trees) as the element that specifies the target attribute.

For value type `URI` the value matches the [generic URI syntax](https://www.ietf.org/rfc/rfc3986.txt).
jeeyyy marked this conversation as resolved.
Show resolved Hide resolved

**Note:** Only for [WAI-ARIA required properties](https://www.w3.org/TR/wai-aria-1.1/#requiredState) with value types `ID Reference` and `ID Reference List` is there a requirement that the elements with the given ids actually exists. For non-required properties, this is not a requirement.

**Note:**
For value type `URI`, this rule does not require that the destination URI exists.
Each test target has a valid value according to its [WAI-ARIA 1.1 value type][].

## Assumptions

This rule catches values that are undefined in [WAI-ARIA Specifications][], and where the resulting behavior in user agents are also undefined in WAI-ARIA. This might lead to accessibility issues, if the intention was to use behavior defined in [WAI-ARIA Specifications][]. When values are used that do not have a defined behavior in [WAI-ARIA Specifications][], the HTML/SVG specification decides what default values should be used, since it is defined here what should happen when an invalid value is used for an attribute. If the default value for invalid attribute values happens to match the author's intention for the value, there will not be an accessibility issue.
This rule assumes that the default value of the attributes do not match the author's intention. ARIA state and properties have a default value as defined in the [WAI-ARIA Specifications][], and this default is used when the provided value is invalid. In some case, the default value may happen to match the author's intention in using this attribute. In such a case, the rule will fail without creating an accessibility issue.

## Accessibility Support

Some user agents treat the value of `aria-*` attribute as case-sensitive (even when these are not ID) while some treat them as case-insensitive.
Some user agents treat the value of `aria-*` attributes as case-sensitive (even when these are not ID) while some treat them as case-insensitive.

## Background

Expand All @@ -53,45 +44,41 @@ Some user agents treat the value of `aria-*` attribute as case-sensitive (even w
- [WAI-ARIA 1.1, Characteristics of States and Properties, Value](https://www.w3.org/TR/wai-aria/#propcharacteristic_value)
- [Uniform Resource Identifier (URI): Generic Syntax (RFC 3986)](https://www.ietf.org/rfc/rfc3986.txt)

Depending on the role of an elements, certain WAI-ARIA properties are or not required. This rule considers that when such a property has a value type of `ID reference` or `ID reference list`, then an element with one of the given ids must exist. On another hand, if a property that is not required refers to an incorrect id, it is less clear that this will cause an accessibility issue (the property is not required on the first place, so the element can live without it, and maybe later interaction with the page will create the correct id and this is the intended behavior). Therefore, the rule has no extra requirement for properties with type `ID reference` or `ID reference list` that are not required.

For value type `URI`, this rule does not require that the destination URI exists. Testing that the link is not dead is out of scope for the rule and therefore ignored.

## Test Cases

### Passed

#### Passed Example 1

`aria-required` property with valid true/false value
This `div` element has an `aria-required` property with valid `true/false` value.

```html
<div role="textbox" aria-required="true" aria-label="A required textbox"></div>
jeeyyy marked this conversation as resolved.
Show resolved Hide resolved
```

#### Passed Example 2

`aria-expanded` state with valid true/false/undefined value
This `div` element has an `aria-expanded` state with valid `true/false/undefined` value.

```html
<div role="button" aria-expanded="undefined">A button</div>
```

#### Passed Example 3

`aria-pressed` state with valid tristate value
This `div` element has an `aria-pressed` state with valid tristate value.

```html
<div role="button" aria-pressed="mixed">An other button</div>
```

#### Passed Example 4

`aria-errormessage` property with valid ID reference value

```html
<div role="textbox" aria-errormessage="my-error" aria-label="A textbox"></div>
```

#### Passed Example 5

`aria-owns` property with valid ID reference list value
This `div` element with the `aria-owns` property, has a valid ID reference list value.

```html
<h1>Shopping list</h1>
Expand All @@ -100,166 +87,160 @@ Some user agents treat the value of `aria-*` attribute as case-sensitive (even w
<div id="item2">Bananas</div>
```

#### Passed Example 6
#### Passed Example 5

`aria-rowindex` property with valid integer value
This `div` element has an `aria-rowindex` property with valid integer value.

```html
<div role="gridcell" aria-rowindex="2">Fred</div>
```

#### Passed Example 7
#### Passed Example 6

`aria-valuemin`, `aria-valuemax` and `aria-valuenow` properties with valid number values
This `div` element has an `aria-valuemin`, `aria-valuemax` and `aria-valuenow` properties with valid number values.

```html
<div role="spinbutton" aria-valuemin="1.0" aria-valuemax="2.0" aria-valuenow="1.5" aria-label="Select a value"></div>
```

#### Passed Example 8
#### Passed Example 7

`aria-placeholder` property with valid string value
This `div` element has an `aria-placeholder` property with valid string value.

```html
<div role="textbox" aria-placeholder="MM-DD-YYYY" aria-label="Your birthdate">
MM-DD-YYYY
</div>
```

#### Passed Example 9
#### Passed Example 8

`aria-dropeffect` property with valid token list value
This `div` element has an `aria-dropeffect` property with valid token list value.

```html
<div role="dialog" aria-dropeffect="copy move"></div>
```

#### Passed Example 10
#### Passed Example 9

`aria-controls`, which is a required property for the role `scrollbar`, has `ID Reference list` that references at least one element existing in the same document tree.
The second `div` element has an `aria-controls`, which is a required property for the role `scrollbar`, has `ID Reference list` that references at least one element existing in the same document tree.
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

```html
<div id="content1">Lorem ipsum...</div>
<div
role="scrollbar"
aria-controls="content1 content2"
aria-orientation="vertical"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="25"
jeeyyy marked this conversation as resolved.
Show resolved Hide resolved
></div>
<div role="scrollbar" aria-controls="content1 content2"></div>
```

#### Passed Example 10

This `div` element has an `aria-errormessage`, which is not a required property & therefore it is not essential that the element referred by the `ID reference` exists, although this element may be added programmatically when an error is detected.

```html
<div role="textbox" aria-errormessage="my-error" aria-label="A textbox"></div>
```

### Failed

#### Failed Example 1

`aria-required` property with invalid true/false value
This `div` element has an `aria-required` property with invalid `true/false` value.

```html
<div role="textbox" aria-required="undefined" aria-label="A required textbox"></div>
```

#### Failed Example 2

`aria-expanded` state with invalid true/false/undefined value
This `div` element has an `aria-expanded` state with invalid `true/false/undefined` value.

```html
<div role="button" aria-expanded="mixed">A button</div>
```

#### Failed Example 3

`aria-pressed` state with invalid tristate value
This `div` element has an `aria-pressed` state with invalid tristate value.

```html
<div role="button" aria-pressed="horizontal">An other button</div>
```

#### Failed Example 4

`aria-errormessage` property with invalid ID reference value, since space is not allowed in a single ID
This `div` element has an `aria-errormessage` property with invalid ID reference value, since space is not allowed in a single ID.

```html
<div role="textbox" aria-errormessage="error1 error2" aria-label="A textbox with an error"></div>
```

#### Failed Example 5

`aria-rowindex` property with invalid integer value
This `div` element has an `aria-rowindex` property with invalid integer value.

```html
<div role="gridcell" aria-rowindex="2.5">Fred</div>
```

#### Failed Example 6

`aria-valuemin`, `aria-valuemax` and `aria-valuenow` property with invalid number values
This `div` element has an `aria-valuemin`, `aria-valuemax` and `aria-valuenow` property with invalid number values.

```html
<div role="spinbutton" aria-valuemin="one" aria-valuemax="three" aria-valuenow="two" aria-label="Choose a value"></div>
```

#### Failed Example 7

`aria-live` property with invalid token value
This `div` element has an `aria-live` property with invalid token value.

```html
<div role="main" aria-live="nope"></div>
```

#### Failed Example 8

Element with invalid token list value
This `div` element has an Element with invalid token list value.

```html
<div role="dialog" aria-dropeffect="invalid move"></div>
```

#### Failed Example 9

`aria-expanded` state with invalid true/false/undefined value for custom element
This `div` element has an `aria-expanded` state with invalid `true/false/undefined` value for custom element.

```html
<my-button role="button" aria-expanded="collapsed">My button</my-button>
```

#### Failed Example 10

`aria-controls`, which is a required property for the role `scrollbar`, references an element that does not exist in the same document tree.
This `div` element has an `aria-controls`, which is a required property for the role `scrollbar`, references an element that does not exist in the same document tree.
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

```html
<div
role="scrollbar"
aria-controls="content1"
aria-orientation="vertical"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="25"
></div>
<div role="scrollbar" aria-controls="content1"></div>
```

### Inapplicable

#### Inapplicable Example 1

Element does not have any ARIA states or properties
This `div` element does not have any ARIA states or properties.

```html
<div>Some Content</div>
```

#### Inapplicable Example 2

Element has ARIA role, but no ARIA states or properties
This `div` element has ARIA role, but no ARIA states or properties.

```html
<div role="button">Some Content</div>
```

#### Inapplicable Example 3

`aria-checked` state with empty value
This `div` element has an `aria-checked` state with empty value.

**Note**: The HTML validator flags an `aria-checked` attribute with an empty value as an issue. However WAI-ARIA 1.1 indicates `aria-checked` has a default value of `undefined`.

Expand All @@ -269,10 +250,12 @@ Element has ARIA role, but no ARIA states or properties

#### Inapplicable Example 4

`aria-hidden` state on an element that is not an HTML or SVG element
This `div` element has an `aria-hidden` state on an element that is not an HTML or SVG element.

```xml
<math aria-hidden="true"></math>
```

[wai-aria specifications]: #wai-aria-specifications 'List of WAI-ARIA Specifications'
[wai-aria 1.1 state or property]: https://www.w3.org/TR/wai-aria-1.1/#state_prop_def
[wai-aria 1.1 value type]: https://www.w3.org/TR/wai-aria-1.1/#propcharacteristic_value