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

fix(required-attr): allow aria-valuetext on slider instead of valuenow #4518

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use commons.text.sanitize instead?

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
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
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"]
]
}
Loading