diff --git a/Changelog.md b/Changelog.md index 6ab0c50f..cd995cb3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/src/js/Constants.js b/src/js/Constants.js index bf5e9e6a..0ff0b720 100644 --- a/src/js/Constants.js +++ b/src/js/Constants.js @@ -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" ], diff --git a/test/audits/aria-role-not-scoped-test.js b/test/audits/aria-role-not-scoped-test.js index 7d26c8a7..831fc72f 100644 --- a/test/audits/aria-role-not-scoped-test.js +++ b/test/audits/aria-role-not-scoped-test.js @@ -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); +});