Skip to content

Commit

Permalink
fix(required-attr): allow aria-valuetext on slider instead of valuenow
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Jul 1, 2024
1 parent 0d8a99e commit 57497bd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/checks/aria/aria-required-attr-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export default function ariaRequiredAttrEvaluate(
) {
return true;
}
// Non-normative exception for things like media player seek slider.
// Tested to work in various screen readers.
if (role === 'slider' && virtualNode.attr('aria-valuetext')?.trim()) {
return true;
}

const elmSpec = getElementSpec(virtualNode);
const missingAttrs = requiredAttrs.filter(
Expand Down
7 changes: 7 additions & 0 deletions test/checks/aria/aria-required-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ describe('aria-required-attr', () => {
assert.isTrue(requiredAttrCheck.apply(checkContext, params));
});

it('passes aria-valuenow if element has aria-valuetext', () => {
const params = checkSetup(
'<div id="target" role="slider" aria-valuetext="foo"></div>'
);
assert.isTrue(requiredAttrCheck.apply(checkContext, params));
});

it('passes aria-checkbox if element has checked property', () => {
const params = checkSetup(
'<input id="target" type="checkbox" role="switch">'
Expand Down
7 changes: 7 additions & 0 deletions test/integration/rules/aria-required-attr/required-attr.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
<div role="spinbutton" id="pass11">fail</div>
<div role="separator" id="pass12"></div>
<div role="separator" id="pass13" tabindex="0" aria-valuenow="foo"></div>
<div
role="slider"
id="pass14-aria-valuetext-slider"
aria-valuetext="3 minutes 20 second"
>
ok
</div>

<div role="scrollbar" id="violation1">fail</div>
<div role="slider" id="violation2">fail</div>
Expand Down
3 changes: 2 additions & 1 deletion test/integration/rules/aria-required-attr/required-attr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
["#pass10"],
["#pass11"],
["#pass12"],
["#pass13"]
["#pass13"],
["#pass14-aria-valuetext-slider"]
]
}

0 comments on commit 57497bd

Please sign in to comment.