From d7ba70fc9916cedb2e977c9dc10667985c2bb4ed Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Mon, 20 Jul 2020 17:35:11 +0200 Subject: [PATCH] feat: add layout-table-matches method (#2400) * feat: add layout-table-matches method * chore: add comment * chore: expose layoutTableMatches --- lib/core/base/metadata-function-map.js | 2 ++ lib/rules/layout-table-matches.js | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 lib/rules/layout-table-matches.js diff --git a/lib/core/base/metadata-function-map.js b/lib/core/base/metadata-function-map.js index 72914a876c..b55c64977f 100644 --- a/lib/core/base/metadata-function-map.js +++ b/lib/core/base/metadata-function-map.js @@ -146,6 +146,7 @@ import labelContentNameMismatchMatches from '../../rules/label-content-name-mism import labelMatches from '../../rules/label-matches'; import landmarkHasBodyContextMatches from '../../rules/landmark-has-body-context-matches'; import landmarkUniqueMatches from '../../rules/landmark-unique-matches'; +import layoutTableMatches from '../../rules/layout-table-matches'; import linkInTextBlockMatches from '../../rules/link-in-text-block-matches'; import noAutoplayAudioMatches from '../../rules/no-autoplay-audio-matches'; import noEmptyRoleMatches from '../../rules/no-empty-role-matches'; @@ -307,6 +308,7 @@ const metadataFunctionMap = { 'label-matches': labelMatches, 'landmark-has-body-context-matches': landmarkHasBodyContextMatches, 'landmark-unique-matches': landmarkUniqueMatches, + 'layout-table-matches': layoutTableMatches, 'link-in-text-block-matches': linkInTextBlockMatches, 'no-autoplay-audio-matches': noAutoplayAudioMatches, 'no-empty-role-matches': noEmptyRoleMatches, diff --git a/lib/rules/layout-table-matches.js b/lib/rules/layout-table-matches.js new file mode 100644 index 0000000000..8f97fa0931 --- /dev/null +++ b/lib/rules/layout-table-matches.js @@ -0,0 +1,9 @@ +import { isDataTable } from '../commons/table'; +import { isFocusable } from '../commons/dom'; + +// TODO: es-modules add tests. No way to access this on the `axe` object +function dataTableMatches(node) { + return !isDataTable(node) && !isFocusable(node); +} + +export default dataTableMatches;