Skip to content

Commit

Permalink
Merge pull request #467 from dequelabs/aria-implicit-values
Browse files Browse the repository at this point in the history
fix(aria): Allow implicit attribute values
  • Loading branch information
dylanb authored Aug 7, 2017
2 parents 17b3b38 + b949749 commit 3de1302
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 39 deletions.
17 changes: 7 additions & 10 deletions lib/commons/aria/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ lookupTables.role = {
'checkbox': {
type: 'widget',
attributes: {
required: ['aria-checked']
allowed: ['aria-checked']
},
owned: null,
nameFrom: ['author', 'contents'],
Expand All @@ -250,8 +250,7 @@ lookupTables.role = {
'combobox': {
type: 'composite',
attributes: {
required: ['aria-expanded'],
allowed: ['aria-autocomplete', 'aria-required', 'aria-activedescendant']
allowed: ['aria-expanded', 'aria-autocomplete', 'aria-required', 'aria-activedescendant']
},
owned: {
all: ['listbox', 'textbox']
Expand Down Expand Up @@ -510,7 +509,7 @@ lookupTables.role = {
'menuitemcheckbox': {
type: 'widget',
attributes: {
required: ['aria-checked']
allowed: ['aria-checked']
},
owned: null,
nameFrom: ['author', 'contents'],
Expand All @@ -520,8 +519,7 @@ lookupTables.role = {
'menuitemradio': {
type: 'widget',
attributes: {
allowed: ['aria-selected', 'aria-posinset', 'aria-setsize'],
required: ['aria-checked']
allowed: ['aria-checked', 'aria-selected', 'aria-posinset', 'aria-setsize'],
},
owned: null,
nameFrom: ['author', 'contents'],
Expand Down Expand Up @@ -584,8 +582,7 @@ lookupTables.role = {
'radio': {
type: 'widget',
attributes: {
allowed: ['aria-selected', 'aria-posinset', 'aria-setsize'],
required: ['aria-checked']
allowed: ['aria-checked', 'aria-selected', 'aria-posinset', 'aria-setsize'],
},
owned: null,
nameFrom: ['author', 'contents'],
Expand Down Expand Up @@ -657,8 +654,8 @@ lookupTables.role = {
'scrollbar': {
type: 'widget',
attributes: {
required: ['aria-controls', 'aria-orientation', 'aria-valuenow', 'aria-valuemax', 'aria-valuemin'],
allowed: ['aria-valuetext']
required: ['aria-controls', 'aria-valuenow', 'aria-valuemax', 'aria-valuemin'],
allowed: ['aria-valuetext', 'aria-orientation']
},
owned: null,
nameFrom: ['author'],
Expand Down
6 changes: 2 additions & 4 deletions test/checks/aria/required-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ describe('aria-required-attr', function () {

it('should detect missing attributes', function () {
var node = document.createElement('div');
node.setAttribute('role', 'checkbox');
node.setAttribute('role', 'slider');
node.id = 'test';
node.tabIndex = 1;
fixture.appendChild(node);

assert.isFalse(checks['aria-required-attr'].evaluate.call(checkContext, node));
assert.deepEqual(checkContext._data, ['aria-checked']);


assert.deepEqual(checkContext._data, ['aria-valuenow', 'aria-valuemax', 'aria-valuemin']);
});

it('should return true if there is no role', function () {
Expand Down
26 changes: 6 additions & 20 deletions test/integration/rules/aria-required-attr/required-attr.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
<div role="scrollbar" id="pass1" aria-controls="value" aria-orientation="value" aria-valuenow="value" aria-valuemax="value" aria-valuemin="value">ok</div>
<div role="slider" id="pass2" aria-valuenow="value" aria-valuemax="value" aria-valuemin="value">ok</div>
<div role="spinbutton" id="pass3" aria-valuenow="value" aria-valuemax="value" aria-valuemin="value">ok</div>

<div role="checkbox" id="pass1" aria-checked="value">ok</div>
<div role="combobox" id="pass2" aria-expanded="value">ok</div>
<div role="menuitemcheckbox" id="pass3" aria-checked="value">ok</div>
<div role="menuitemradio" id="pass4" aria-checked="value">ok</div>
<div role="radio" id="pass5" aria-checked="value">ok</div>
<div role="scrollbar" id="pass6" aria-controls="value" aria-orientation="value" aria-valuenow="value" aria-valuemax="value" aria-valuemin="value">ok</div>
<div role="slider" id="pass7" aria-valuenow="value" aria-valuemax="value" aria-valuemin="value">ok</div>
<div role="spinbutton" id="pass8" aria-valuenow="value" aria-valuemax="value" aria-valuemin="value">ok</div>
<div role="switch" id="pass9" aria-checked="value">ok</div>


<div role="checkbox" id="violation1">fail</div>
<div role="combobox" id="violation2">fail</div>
<div role="menuitemcheckbox" id="violation3">fail</div>
<div role="menuitemradio" id="violation4">fail</div>
<div role="radio" id="violation5">fail</div>
<div role="scrollbar" id="violation6">fail</div>
<div role="slider" id="violation7">fail</div>
<div role="spinbutton" id="violation8">fail</div>
<div role="switch" id="violation9">fail</div>
<div role="scrollbar" id="violation1">fail</div>
<div role="slider" id="violation2">fail</div>
<div role="spinbutton" id="violation3">fail</div>
7 changes: 2 additions & 5 deletions test/integration/rules/aria-required-attr/required-attr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
"description": "aria-required-attr tests",
"rule": "aria-required-attr",
"violations": [
["#violation1"], ["#violation2"], ["#violation3"], ["#violation4"],
["#violation5"], ["#violation6"], ["#violation7"], ["#violation8"],
["#violation9"]
["#violation1"], ["#violation2"], ["#violation3"]
],
"passes": [
["#pass1"], ["#pass2"], ["#pass3"], ["#pass4"], ["#pass5"], ["#pass6"],
["#pass7"], ["#pass8"], ["#pass9"]
["#pass1"], ["#pass2"], ["#pass3"]
]
}

0 comments on commit 3de1302

Please sign in to comment.