Skip to content

Commit

Permalink
fix(aria-valid-attr-value): allow empty value on aria-braille* & aria…
Browse files Browse the repository at this point in the history
…-valuetext (#4109)

* fix(aria-valid-attr-value): allow  empty value on aria-braille* & aria-valuetext

* Fix test

* Fix tests
  • Loading branch information
WilcoFiers authored Aug 1, 2023
1 parent 758b069 commit c4c3e65
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
5 changes: 4 additions & 1 deletion lib/standards/aria-attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ const ariaAttrs = {
},
'aria-braillelabel': {
type: 'string',
allowEmpty: true,
global: true
},
'aria-brailleroledescription': {
type: 'string',
allowEmpty: true,
global: true
},
'aria-busy': {
Expand Down Expand Up @@ -214,7 +216,8 @@ const ariaAttrs = {
type: 'decimal'
},
'aria-valuetext': {
type: 'string'
type: 'string',
allowEmpty: true
}
};

Expand Down
13 changes: 13 additions & 0 deletions test/checks/aria/valid-attr-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ describe('aria-valid-attr-value', function () {
});

describe('null values', function () {
afterEach(() => {
axe.reset();
});

it('returns undefined when a boolean attribute is null', function () {
var vNode = queryFixture(
'<div id="target" role="checkbox" aria-checked></div>'
Expand Down Expand Up @@ -249,6 +253,15 @@ describe('aria-valid-attr-value', function () {
});

it('returns false for empty string values that are not allowed to be empty', function () {
axe.configure({
standards: {
ariaAttrs: {
'aria-valuetext': {
allowEmpty: false
}
}
}
});
var vNode = queryFixture(
'<div id="target" aria-valuetext="" role="range"></div>'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,57 +39,56 @@ <h2>Violations</h2>
hi
</div>
<div id="violation35-ref"></div>
<div aria-valuetext="" id="violation36"></div>
<!-- don't allow empty aria-valuetext -->

<div aria-level="0" id="violation37">hi</div>
<div aria-level="-1" id="violation38">hi</div>
<div aria-level="-22" id="violation39">hi</div>
<div aria-level="0" id="violation36">hi</div>
<div aria-level="-1" id="violation37">hi</div>
<div aria-level="-22" id="violation38">hi</div>

<div aria-posinset="0" id="violation40">hi</div>
<div aria-posinset="-1" id="violation41">hi</div>
<div aria-posinset="-22" id="violation42">hi</div>
<div aria-posinset="0" id="violation39">hi</div>
<div aria-posinset="-1" id="violation40">hi</div>
<div aria-posinset="-22" id="violation41">hi</div>

<div aria-setsize="-22" id="violation43">hi</div>
<div aria-setsize="-22" id="violation42">hi</div>

<div>
<input
type="text"
id="violation44"
id="violation43"
aria-invalid="true"
aria-errormessage="violation44-ref"
aria-errormessage="violation43-ref"
/>
<div id="violation44-ref" hidden>Error message 1</div>
<div id="violation43-ref" hidden>Error message 1</div>
</div>

<div>
<input
type="text"
id="violation45"
id="violation44"
aria-invalid="true"
aria-errormessage="violation45-ref"
aria-errormessage="violation44-ref"
/>
<div id="violation45-ref" style="display: none">Error message 1</div>
<div id="violation44-ref" style="display: none">Error message 1</div>
</div>

<div>
<input
type="text"
id="violation46"
id="violation45"
aria-invalid="true"
aria-errormessage="violation46-ref"
aria-errormessage="violation45-ref"
/>
<div id="violation46-ref" style="visibility: hidden">Error message 1</div>
<div id="violation45-ref" style="visibility: hidden">Error message 1</div>
</div>

<div>
<input
type="text"
id="violation47"
id="violation46"
aria-invalid="true"
aria-errormessage="violation47-ref"
aria-errormessage="violation46-ref"
/>
<div id="violation47-ref" aria-hidden="true">Error message 1</div>
<div id="violation46-ref" aria-hidden="true">Error message 1</div>
</div>
</div>
<h2>Possible False Positives</h2>
Expand Down Expand Up @@ -343,6 +342,12 @@ <h2>Possible False Positives</h2>
aria-errormessage="violation44-ref"
/>
</div>
<div
id="pass191"
aria-braillelabel=""
aria-brailleroledescription=""
aria-valuetext=""
></div>

<div id="ref">Hi</div>
<div id="ref2">Hi2</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
["#violation43"],
["#violation44"],
["#violation45"],
["#violation46"],
["#violation47"]
["#violation46"]
],
"passes": [
["#pass1"],
Expand Down Expand Up @@ -226,7 +225,8 @@
["#pass187"],
["#pass188"],
["#pass189"],
["#pass190"]
["#pass190"],
["#pass191"]
],
"incomplete": [
["#incomplete1"],
Expand Down
3 changes: 1 addition & 2 deletions test/integration/virtual-rules/aria-valid-attr-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('aria-valid-attr-value virtual-rule', function () {
attributes: {
role: 'slider',
'aria-valuemin': true,
'aria-valuetext': '',
'aria-expanded': 'grid',
'aria-haspopup': 'Range',
'aria-valuenow': false
Expand All @@ -34,7 +33,7 @@ describe('aria-valid-attr-value virtual-rule', function () {
assert.lengthOf(results.violations, 1);
assert.lengthOf(results.incomplete, 0);

assert.lengthOf(results.violations[0].nodes[0].all[0].data, 5);
assert.lengthOf(results.violations[0].nodes[0].all[0].data, 4);
});

it('should only mark invalid values', function () {
Expand Down

0 comments on commit c4c3e65

Please sign in to comment.