1.0.9 • Published 8 months ago

add-aria-to-table v1.0.9

Weekly downloads
-
License
LGPL-3.0
Repository
github
Last release
8 months ago

Adding ARIA Roles to a Table

Adds or re-adds ARIA roles to an HTML table and its child elements. Intended to re-add the ARIA to a table that has been made responsive by CSS.

For simple tables without header cells or only row header cells no actions are required but for more complex tables with header cells that are rowheaders, colgroups or rowgroups the appropriate roles are required on the header cells. See the section below for the appropriate roles.

ARIA Roles

The roles that are added to each type of table element (ELEMENT: role) are:

  • TABLE: table
  • THEAD, TFOOT, TBODY: rowgroup
  • TR: row
  • TD: cell
  • TH (with scope "col" OR without scope): columnheader
  • TH (with scope "row"): rowheader
  • TH (with scope "colgroup"): columngroupheader
  • TH (with scope "rowgroup"): rowgroupheader

Note:
The table header cell elements (TH) may not contain the scope "auto" as no ARIA role can be inferred from this scope.

Usage

import { addAriaToAllTables, addAriaToTable }
from "./node_modules/add-aria-to-table/index.js";

// Adding ARIA to every html table.
addAriaToAllTables();

// Adding ARIA to a specific html table (may not be null).
const table = document.querySelector("table");
if (table !== null) {
  addAriaToTable(table);
}

// Alternatively the addAriaToTable() function can also be used to
// add ARIA to every HTML table.
document.querySelectorAll("table").forEach(table => addAriaToTable(table));
1.0.9

8 months ago

1.0.8

9 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago