get-all-cells.js 707 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * Returns all cells contained in given HTMLTableElement
  3. * @method getAllCells
  4. * @memberof axe.commons.table
  5. * @instance
  6. * @param {HTMLTableElement} tableElm Table Element to get cells from
  7. * @return {Array<HTMLTableCellElement>}
  8. */
  9. function getAllCells(tableElm) {
  10. var rowIndex, cellIndex, rowLength, cellLength;
  11. var cells = [];
  12. for (
  13. rowIndex = 0, rowLength = tableElm.rows.length;
  14. rowIndex < rowLength;
  15. rowIndex++
  16. ) {
  17. for (
  18. cellIndex = 0, cellLength = tableElm.rows[rowIndex].cells.length;
  19. cellIndex < cellLength;
  20. cellIndex++
  21. ) {
  22. cells.push(tableElm.rows[rowIndex].cells[cellIndex]);
  23. }
  24. }
  25. return cells;
  26. }
  27. export default getAllCells;