Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Fix ARIA tablist and ARIA tab scope #207

Merged
merged 4 commits into from
Jul 31, 2015
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
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Add a special case to handle color `"transparent"` to fix (#180).
* Fix `matchSelector` not working properly in browser environments without vendor prefixes (#189).
* Fix false positives on elements with no role for Unsupported ARIA Attribute rule (#178 and #199).
* Fix ARIA `tablist` and ARIA `tab` scope (#204)

## 2.8.0 - 2015-07-24

Expand Down
6 changes: 3 additions & 3 deletions src/js/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,14 @@ axs.constants.ARIA_ROLES = {
"tab": {
"namefrom": [ "contents", "author" ],
"parent": [ "sectionhead", "widget" ],
"properties": [ "aria-selected" ]
"properties": [ "aria-selected" ],
"scope": [ "tablist" ]
},
"tablist": {
"mustcontain": [ "tab" ],
"namefrom": [ "author" ],
"parent": [ "composite", "directory" ],
"properties": [ "aria-level" ],
"scope": [ "tablist" ]
"properties": [ "aria-level" ]
},
"tabpanel": {
"namefrom": [ "author" ],
Expand Down
31 changes: 31 additions & 0 deletions test/audits/aria-role-not-scoped-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,34 @@ test('Scope role missing', function() {
equal(actual.result, axs.constants.AuditResult.FAIL);
deepEqual(actual.elements, expected);
});

test('Scope role present - tablist', function() {
var rule = axs.AuditRules.getRule('ariaRoleNotScoped');
var fixture = document.getElementById('qunit-fixture');
var container = fixture.appendChild(document.createElement('ul'));
container.setAttribute('role', 'tablist');
for (var i = 0; i < 4; i++) {
var item = container.appendChild(document.createElement('li'));
item.setAttribute('role', 'tab');
}

var actual = rule.run({ scope: fixture });
equal(actual.result, axs.constants.AuditResult.PASS);
deepEqual(actual.elements, []);
});

test('Scope role missing - tab', function() {
var rule = axs.AuditRules.getRule('ariaRoleNotScoped');
var fixture = document.getElementById('qunit-fixture');
var container = fixture.appendChild(document.createElement('ul'));
var expected = [];
for (var i = 0; i < 4; i++) {
var item = container.appendChild(document.createElement('li'));
item.setAttribute('role', 'tab');
expected.push(item);
}

var actual = rule.run({ scope: fixture });
equal(actual.result, axs.constants.AuditResult.FAIL);
deepEqual(actual.elements, expected);
});