Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(th-has-data-cells): empty cells will now pass #1659

Merged
merged 5 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
14 changes: 4 additions & 10 deletions lib/checks/tables/th-has-data-cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,19 @@ headers.forEach(header => {

const pos = tableUtils.getCellPosition(header, tableGrid);

// look for any column cell that has content and is not a column header
// ensure column header has at least 1 non-header cell
let hasCell = false;
if (tableUtils.isColumnHeader(header)) {
hasCell = tableUtils
.traverse('down', pos, tableGrid)
.some(
cell =>
axe.commons.dom.hasContent(cell) && !tableUtils.isColumnHeader(cell)
);
.find(cell => !tableUtils.isColumnHeader(cell));
}

// look for any row cell that has content and is not a row header
// ensure row header has at least 1 non-header cell
if (!hasCell && tableUtils.isRowHeader(header)) {
hasCell = tableUtils
.traverse('right', pos, tableGrid)
.some(
cell =>
axe.commons.dom.hasContent(cell) && !tableUtils.isRowHeader(cell)
);
.find(cell => !tableUtils.isRowHeader(cell));
}

// report the node as having failed
Expand Down
4 changes: 2 additions & 2 deletions test/checks/tables/th-has-data-cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('th-has-data-cells', function() {
);
});

it('should return undefined if all data cells are empty', function() {
it('should return true if all data cells are empty', function() {
fixture.innerHTML =
'<table>' +
' <tr> <th>hi</th> <td></td> </tr>' +
Expand All @@ -121,7 +121,7 @@ describe('th-has-data-cells', function() {

axe.testUtils.flatTreeSetup(fixture);
var node = fixture.querySelector('table');
assert.isUndefined(
assert.isTrue(
checks['th-has-data-cells'].evaluate.call(checkContext, node)
);
});
Expand Down
11 changes: 0 additions & 11 deletions test/integration/full/incomplete/th-has-data-cells.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@
</tr>
</table>

<table id="table2">
straker marked this conversation as resolved.
Show resolved Hide resolved
<tr>
<th>hi</th>
<td></td>
</tr>
<tr>
<th>hi</th>
<td></td>
</tr>
</table>

<table id="table3">
<tr>
<td>axe</td>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/full/incomplete/th-has-data-cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('th-has-data-cells cantTell test', function() {
describe('incomplete data', function() {
it('should be incomplete for missing or empty data cells', function() {
var resultNodes = results.incomplete[0].nodes;
assert.lengthOf(resultNodes, 3);
assert.lengthOf(resultNodes, 2);
resultNodes[0].any.forEach(function(check) {
assert.match(check.message, 'Table data cells are missing or empty');
});
Expand Down