From ef490009ffc2df8cced680809ea08fd740bfb429 Mon Sep 17 00:00:00 2001 From: Rick Date: Tue, 28 Jul 2015 07:47:38 +1000 Subject: [PATCH 1/4] Fix tablist scope --- src/js/Constants.js | 3 +-- test/audits/aria-role-not-scoped-test.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/js/Constants.js b/src/js/Constants.js index bf5e9e6a..30a41294 100644 --- a/src/js/Constants.js +++ b/src/js/Constants.js @@ -413,8 +413,7 @@ axs.constants.ARIA_ROLES = { "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..1abbfcb6 100644 --- a/test/audits/aria-role-not-scoped-test.js +++ b/test/audits/aria-role-not-scoped-test.js @@ -79,3 +79,18 @@ 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, []); +}); From ff029fa370581dd0e39b4110563969bc526796bd Mon Sep 17 00:00:00 2001 From: Rick Date: Tue, 28 Jul 2015 07:57:49 +1000 Subject: [PATCH 2/4] Fix tab scope --- src/js/Constants.js | 3 ++- test/audits/aria-role-not-scoped-test.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/js/Constants.js b/src/js/Constants.js index 30a41294..0ff0b720 100644 --- a/src/js/Constants.js +++ b/src/js/Constants.js @@ -407,7 +407,8 @@ axs.constants.ARIA_ROLES = { "tab": { "namefrom": [ "contents", "author" ], "parent": [ "sectionhead", "widget" ], - "properties": [ "aria-selected" ] + "properties": [ "aria-selected" ], + "scope": [ "tablist" ] }, "tablist": { "mustcontain": [ "tab" ], diff --git a/test/audits/aria-role-not-scoped-test.js b/test/audits/aria-role-not-scoped-test.js index 1abbfcb6..0e2c0e2d 100644 --- a/test/audits/aria-role-not-scoped-test.js +++ b/test/audits/aria-role-not-scoped-test.js @@ -94,3 +94,18 @@ test('Scope role present - tablist', function() { 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 expected = []; + for (var i = 0; i < 4; i++) { + var item = fixture.appendChild(document.createElement('span')); + item.setAttribute('role', 'tab'); + expected.push(item); + } + + var actual = rule.run({ scope: fixture }); + equal(actual.result, axs.constants.AuditResult.FAIL); + deepEqual(actual.elements, expected); +}); From 6eaec7e968c8e1b459c787c5f5c97f974e41a730 Mon Sep 17 00:00:00 2001 From: Rick Date: Tue, 28 Jul 2015 08:02:32 +1000 Subject: [PATCH 3/4] changelog --- Changelog.md | 1 + 1 file changed, 1 insertion(+) 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 From efd6891696f80f1fc9e46bf1c96d14d42f399569 Mon Sep 17 00:00:00 2001 From: Rick Date: Sat, 1 Aug 2015 08:32:49 +1000 Subject: [PATCH 4/4] PR feedback --- test/audits/aria-role-not-scoped-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/audits/aria-role-not-scoped-test.js b/test/audits/aria-role-not-scoped-test.js index 0e2c0e2d..831fc72f 100644 --- a/test/audits/aria-role-not-scoped-test.js +++ b/test/audits/aria-role-not-scoped-test.js @@ -98,9 +98,10 @@ test('Scope role present - tablist', function() { 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 = fixture.appendChild(document.createElement('span')); + var item = container.appendChild(document.createElement('li')); item.setAttribute('role', 'tab'); expected.push(item); }