-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rule): Layout-table does not match presentation / none roles (#828)
* fix(layout-table): check for presentation, none roles and isfocusable for matches * fix(layout-table): tests for layout table matches for focusable and non-presentation/none tables
- Loading branch information
1 parent
d280c5f
commit 5651ecc
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
return !axe.commons.table.isDataTable(node); | ||
var role = (node.getAttribute('role') || '').toLowerCase(); | ||
|
||
return !((role === 'presentation' || role === 'none') && | ||
!axe.commons.dom.isFocusable(node)) && | ||
!axe.commons.table.isDataTable(node); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
describe('layout-table-matches', function () { | ||
'use strict'; | ||
|
||
var fixture = document.getElementById('fixture'); | ||
var fixtureSetup = axe.testUtils.fixtureSetup; | ||
var rule; | ||
|
||
beforeEach(function () { | ||
rule = axe._audit.rules.find(function (rule) { | ||
return rule.id === 'layout-table'; | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
fixture.innerHTML = ''; | ||
}); | ||
|
||
it('returns false for element that is not focusable and has presentation role', function () { | ||
fixtureSetup('<table role="presentation"></table>'); | ||
var target = fixture.querySelector('table'); | ||
|
||
assert.isFalse(rule.matches(target)); | ||
}); | ||
|
||
it('returns false for element that is not focusable and has none role', function () { | ||
fixtureSetup('<table role="none"></table>'); | ||
var target = fixture.querySelector('table'); | ||
|
||
assert.isFalse(rule.matches(target)); | ||
}); | ||
|
||
it('returns trie for element that is a table without presentation/none role', function () { | ||
fixtureSetup('<table></table>'); | ||
var target = fixture.querySelector('table'); | ||
|
||
assert.isTrue(rule.matches(target)); | ||
}); | ||
|
||
it('returns true for element that is focusable and has none role', function () { | ||
fixtureSetup('<table role="none" tabindex="0"></table>'); | ||
var target = fixture.querySelector('table'); | ||
|
||
assert.isTrue(rule.matches(target)); | ||
}); | ||
|
||
it('returns true for element that is focusable and has presentation role', function () { | ||
fixtureSetup('<table role="presentation" tabindex="0"></table>'); | ||
var target = fixture.querySelector('table'); | ||
|
||
assert.isTrue(rule.matches(target)); | ||
}); | ||
}); |