From 05ec985dfdb2e569a6db67dc2bf062fa397c2a71 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 26 Jun 2019 15:29:08 -0600 Subject: [PATCH 1/5] fix(th-has-data-cells): empty cells will now pass --- lib/checks/tables/th-has-data-cells.js | 16 +++------------- test/checks/tables/th-has-data-cells.js | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/checks/tables/th-has-data-cells.js b/lib/checks/tables/th-has-data-cells.js index 2bab2164c1..c4a2982ad6 100644 --- a/lib/checks/tables/th-has-data-cells.js +++ b/lib/checks/tables/th-has-data-cells.js @@ -40,25 +40,15 @@ 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 cells are not empty let hasCell = false; if (tableUtils.isColumnHeader(header)) { - hasCell = tableUtils - .traverse('down', pos, tableGrid) - .some( - cell => - axe.commons.dom.hasContent(cell) && !tableUtils.isColumnHeader(cell) - ); + hasCell = tableUtils.traverse('down', pos, tableGrid).length !== 0; } // look for any row cell that has content and is not a row header if (!hasCell && tableUtils.isRowHeader(header)) { - hasCell = tableUtils - .traverse('right', pos, tableGrid) - .some( - cell => - axe.commons.dom.hasContent(cell) && !tableUtils.isRowHeader(cell) - ); + hasCell = tableUtils.traverse('right', pos, tableGrid).length !== 0; } // report the node as having failed diff --git a/test/checks/tables/th-has-data-cells.js b/test/checks/tables/th-has-data-cells.js index 3507734a16..850705fed7 100644 --- a/test/checks/tables/th-has-data-cells.js +++ b/test/checks/tables/th-has-data-cells.js @@ -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 = '' + ' ' + @@ -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) ); }); From 5a36ea72ce567e5d5619a39ef2ae29d54b3faa15 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 26 Jun 2019 15:32:13 -0600 Subject: [PATCH 2/5] filter headers --- lib/checks/tables/th-has-data-cells.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/checks/tables/th-has-data-cells.js b/lib/checks/tables/th-has-data-cells.js index c4a2982ad6..399b7b5fa2 100644 --- a/lib/checks/tables/th-has-data-cells.js +++ b/lib/checks/tables/th-has-data-cells.js @@ -40,15 +40,21 @@ headers.forEach(header => { const pos = tableUtils.getCellPosition(header, tableGrid); - // ensure column cells are not empty + // ensure column header has at least 1 non-header cell let hasCell = false; if (tableUtils.isColumnHeader(header)) { - hasCell = tableUtils.traverse('down', pos, tableGrid).length !== 0; + hasCell = + tableUtils + .traverse('down', pos, tableGrid) + .filter(cell => !tableUtils.isColumnHeader(cell)).length !== 0; } - // 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).length !== 0; + hasCell = + tableUtils + .traverse('right', pos, tableGrid) + .filter(cell => !tableUtils.isRowHeader(cell)).length !== 0; } // report the node as having failed From 17aaede3367ee743dfb1d23aa0dfe92fba8da6c0 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 26 Jun 2019 15:38:53 -0600 Subject: [PATCH 3/5] fix test --- .../full/incomplete/th-has-data-cells.html | 11 ----------- test/integration/full/incomplete/th-has-data-cells.js | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/test/integration/full/incomplete/th-has-data-cells.html b/test/integration/full/incomplete/th-has-data-cells.html index 4aec27f427..187d4ad934 100644 --- a/test/integration/full/incomplete/th-has-data-cells.html +++ b/test/integration/full/incomplete/th-has-data-cells.html @@ -30,17 +30,6 @@
hi
- - - - - - - - - -
hi
hi
- diff --git a/test/integration/full/incomplete/th-has-data-cells.js b/test/integration/full/incomplete/th-has-data-cells.js index 82b165df24..5f26a53293 100644 --- a/test/integration/full/incomplete/th-has-data-cells.js +++ b/test/integration/full/incomplete/th-has-data-cells.js @@ -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'); }); From 6a0663fb39d1fb3482c789e661b039308270eb68 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Thu, 27 Jun 2019 07:48:30 -0600 Subject: [PATCH 4/5] find instead of filter --- lib/checks/tables/th-has-data-cells.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/checks/tables/th-has-data-cells.js b/lib/checks/tables/th-has-data-cells.js index 399b7b5fa2..9b46be722f 100644 --- a/lib/checks/tables/th-has-data-cells.js +++ b/lib/checks/tables/th-has-data-cells.js @@ -43,18 +43,16 @@ headers.forEach(header => { // ensure column header has at least 1 non-header cell let hasCell = false; if (tableUtils.isColumnHeader(header)) { - hasCell = - tableUtils - .traverse('down', pos, tableGrid) - .filter(cell => !tableUtils.isColumnHeader(cell)).length !== 0; + hasCell = tableUtils + .traverse('down', pos, tableGrid) + .find(cell => !tableUtils.isColumnHeader(cell)); } // ensure row header has at least 1 non-header cell if (!hasCell && tableUtils.isRowHeader(header)) { - hasCell = - tableUtils - .traverse('right', pos, tableGrid) - .filter(cell => !tableUtils.isRowHeader(cell)).length !== 0; + hasCell = tableUtils + .traverse('right', pos, tableGrid) + .find(cell => !tableUtils.isRowHeader(cell)); } // report the node as having failed From 2fa2edbc4a9040b165b2f4b650d2cb261fb031c2 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 3 Jul 2019 09:18:11 -0600 Subject: [PATCH 5/5] move test to passes --- .../rules/th-has-data-cells/th-has-data-cells.html | 11 +++++++++++ .../rules/th-has-data-cells/th-has-data-cells.json | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/integration/rules/th-has-data-cells/th-has-data-cells.html b/test/integration/rules/th-has-data-cells/th-has-data-cells.html index ba04856ee5..43a44421fd 100644 --- a/test/integration/rules/th-has-data-cells/th-has-data-cells.html +++ b/test/integration/rules/th-has-data-cells/th-has-data-cells.html @@ -61,6 +61,17 @@
axe
+ + + + + + + + + +
hi
hi
+ diff --git a/test/integration/rules/th-has-data-cells/th-has-data-cells.json b/test/integration/rules/th-has-data-cells/th-has-data-cells.json index 2fe908052f..6bec1f1b27 100644 --- a/test/integration/rules/th-has-data-cells/th-has-data-cells.json +++ b/test/integration/rules/th-has-data-cells/th-has-data-cells.json @@ -14,6 +14,7 @@ ["#pass4"], ["#pass5"], ["#pass6"], - ["#pass7"] + ["#pass7"], + ["#pass8"] ] }
axe