Skip to content

Commit

Permalink
feat(aria-roles): permit fallback roles (#3683)
Browse files Browse the repository at this point in the history
* feat(aria-roles): permit fallback roles

* fix virtual-rule test

* Add non-deprecation note
  • Loading branch information
WilcoFiers committed Sep 29, 2022
1 parent 738dd8f commit 5665260
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion doc/rule-descriptions.md
Expand Up @@ -25,7 +25,7 @@
| [aria-required-children](https://dequeuniversity.com/rules/axe/4.4/aria-required-children?application=RuleDescription) | Ensures elements with an ARIA role that require child roles contain them | Critical | cat.aria, wcag2a, wcag131 | failure, needs review | [bc4a75](https://act-rules.github.io/rules/bc4a75) |
| [aria-required-parent](https://dequeuniversity.com/rules/axe/4.4/aria-required-parent?application=RuleDescription) | Ensures elements with an ARIA role that require parent roles are contained by them | Critical | cat.aria, wcag2a, wcag131 | failure | [ff89c9](https://act-rules.github.io/rules/ff89c9) |
| [aria-roledescription](https://dequeuniversity.com/rules/axe/4.4/aria-roledescription?application=RuleDescription) | Ensure aria-roledescription is only used on elements with an implicit or explicit role | Serious | cat.aria, wcag2a, wcag412 | failure, needs review | |
| [aria-roles](https://dequeuniversity.com/rules/axe/4.4/aria-roles?application=RuleDescription) | Ensures all elements with a role attribute use a valid value | Minor, Serious, Critical | cat.aria, wcag2a, wcag412 | failure, needs review | [674b10](https://act-rules.github.io/rules/674b10) |
| [aria-roles](https://dequeuniversity.com/rules/axe/4.4/aria-roles?application=RuleDescription) | Ensures all elements with a role attribute use a valid value | Minor, Serious, Critical | cat.aria, wcag2a, wcag412 | failure | [674b10](https://act-rules.github.io/rules/674b10) |
| [aria-toggle-field-name](https://dequeuniversity.com/rules/axe/4.4/aria-toggle-field-name?application=RuleDescription) | Ensures every ARIA toggle field has an accessible name | Moderate, Serious | cat.aria, wcag2a, wcag412, ACT | failure, needs review | [e086e5](https://act-rules.github.io/rules/e086e5) |
| [aria-tooltip-name](https://dequeuniversity.com/rules/axe/4.4/aria-tooltip-name?application=RuleDescription) | Ensures every ARIA tooltip node has an accessible name | Serious | cat.aria, wcag2a, wcag412 | failure, needs review | |
| [aria-valid-attr-value](https://dequeuniversity.com/rules/axe/4.4/aria-valid-attr-value?application=RuleDescription) | Ensures all ARIA attributes have valid values | Serious, Critical | cat.aria, wcag2a, wcag412 | failure, needs review | [6a7281](https://act-rules.github.io/rules/6a7281) |
Expand Down
2 changes: 2 additions & 0 deletions lib/checks/aria/fallbackrole-evaluate.js
Expand Up @@ -2,6 +2,8 @@ import { tokenList } from '../../core/utils';
import { getImplicitRole } from '../../commons/aria';

/**
* NOTE: This check is no longer used, but it was not deprecated
* so it can be used in custom rulesets.
* @return {Boolean} True if the element has no implicit role and uses both none and presentation as explicit roles
*/
function nonePresentationOnElementWithNoImplicitRole(
Expand Down
8 changes: 1 addition & 7 deletions lib/rules/aria-roles.json
Expand Up @@ -10,11 +10,5 @@
},
"all": [],
"any": [],
"none": [
"fallbackrole",
"invalidrole",
"abstractrole",
"unsupportedrole",
"deprecatedrole"
]
"none": ["invalidrole", "abstractrole", "unsupportedrole", "deprecatedrole"]
}
8 changes: 4 additions & 4 deletions test/integration/rules/aria-roles/aria-roles.html
Expand Up @@ -112,6 +112,8 @@
<div role="comment" id="pass114">ok</div>
<div role="mark" id="pass115">ok</div>
<div role="suggestion" id="pass116">ok</div>
<!-- fallback roles -->
<div role="button alert" id="pass117">fail</div>
</div>
<div id="violation">
<!-- abstract roles -->
Expand All @@ -130,11 +132,9 @@
<!-- invalid roles -->
<div role="lol" id="fail13">fail</div>
<!-- unsupported roles -->
<!-- fallback roles -->
<div role="button alert" id="fail14">fail</div>
<!-- deprecated roles-->
<div role="doc-biblioentry" id="fail15">fail</div>
<div role="doc-endnote" id="fail16">fail</div>
<div role="doc-biblioentry" id="fail14">fail</div>
<div role="doc-endnote" id="fail15">fail</div>
</div>

<!-- inapplicable -->
Expand Down
6 changes: 3 additions & 3 deletions test/integration/rules/aria-roles/aria-roles.json
Expand Up @@ -16,8 +16,7 @@
["#fail12"],
["#fail13"],
["#fail14"],
["#fail15"],
["#fail16"]
["#fail15"]
],
"passes": [
["#pass1"],
Expand Down Expand Up @@ -132,6 +131,7 @@
["#pass113"],
["#pass114"],
["#pass115"],
["#pass116"]
["#pass116"],
["#pass117"]
]
}
18 changes: 9 additions & 9 deletions test/integration/virtual-rules/aria-roles.js
@@ -1,5 +1,5 @@
describe('aria-roles virtual-rule', function() {
it('should pass for valid role', function() {
describe('aria-roles virtual-rule', function () {
it('should pass for valid role', function () {
var results = axe.runVirtualRule('aria-roles', {
nodeName: 'div',
attributes: {
Expand All @@ -12,7 +12,7 @@ describe('aria-roles virtual-rule', function() {
assert.lengthOf(results.incomplete, 0);
});

it('should fail for abstract role', function() {
it('should fail for abstract role', function () {
var results = axe.runVirtualRule('aria-roles', {
nodeName: 'div',
attributes: {
Expand All @@ -25,7 +25,7 @@ describe('aria-roles virtual-rule', function() {
assert.lengthOf(results.incomplete, 0);
});

it('should fail for invalid role', function() {
it('should fail for invalid role', function () {
var results = axe.runVirtualRule('aria-roles', {
nodeName: 'div',
attributes: {
Expand All @@ -38,20 +38,20 @@ describe('aria-roles virtual-rule', function() {
assert.lengthOf(results.incomplete, 0);
});

it('should fail for fallback role', function() {
it('should pass for fallback role', function () {
var results = axe.runVirtualRule('aria-roles', {
nodeName: 'div',
attributes: {
role: 'button alert'
role: 'presentation none'
}
});

assert.lengthOf(results.passes, 0);
assert.lengthOf(results.violations, 1);
assert.lengthOf(results.passes, 1);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});

it('should fail for unsupported role', function() {
it('should fail for unsupported role', function () {
axe.configure({
standards: {
ariaRoles: {
Expand Down

0 comments on commit 5665260

Please sign in to comment.