1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-03-15 16:29:16 +01:00

Fix: Accessiblity - Add role=row attribute to table rows

- Feedback from James Craig on improving the accessiblity of DataTables.
  Since the `role=grid` option is added to the DataTables table, we
  should also add `role=row` to the rows in the table so the browsers
  can see them correctly. As James notes, it is debatable if this is
  needed or not but it is required in current Chrome and Webkit.

- Webkit do now allow roles to be optional in the nighties - see:
  https://bugs.webkit.org/show_bug.cgi?id=131819 . Once Apple deploy
  this in a Safari update, and Chrome also deploy support, I think this
  should be removed from DataTables core, since it will no longer be
  needed in the latest browsers, and manipulating the DOM can hit
  performance a bit.
This commit is contained in:
Allan Jardine 2014-04-22 09:58:32 +01:00
parent 7ab49af0b6
commit 80e748cc11
2 changed files with 8 additions and 1 deletions

View File

@ -1 +1 @@
d9f416232bb33d53cc9a6f006416bf19c385ebe4
d3de0eee0b27a066360fdaa17488d23c44d943a6

View File

@ -1587,6 +1587,10 @@
_fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
}
// Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
// and deployed
row.nTr.setAttribute( 'role', 'row' );
}
@ -1676,6 +1680,9 @@
if ( createHeader ) {
_fnDetectHeader( oSettings.aoHeader, thead );
}
/* ARIA role for the rows */
$(thead).find('>tr').attr('role', 'row');
/* Deal with the footer - add classes if required */
$(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );