Sha256: bf1d6eb5a1ed092636eeba0d570938bf91ffb27ac90d6af818c414b88ff3caf4

Contents?: true

Size: 1023 Bytes

Versions: 271

Compression:

Stored size: 1023 Bytes

Contents

/*global table */

/**
 * Converts a table to an Array of arrays, normalized for row and column spans
 * @method toGrid
 * @memberof axe.commons.table
 * @instance
 * @param  {HTMLTableElement} node The table to convert
 * @return {Array<HTMLTableCellElement>} Array of HTMLTableCellElements
 */
table.toGrid = axe.utils.memoize(function(node) {
	var table = [];
	var rows = node.rows;
	for (var i = 0, rowLength = rows.length; i < rowLength; i++) {
		var cells = rows[i].cells;
		table[i] = table[i] || [];

		var columnIndex = 0;

		for (var j = 0, cellLength = cells.length; j < cellLength; j++) {
			for (var colSpan = 0; colSpan < cells[j].colSpan; colSpan++) {
				for (var rowSpan = 0; rowSpan < cells[j].rowSpan; rowSpan++) {
					table[i + rowSpan] = table[i + rowSpan] || [];
					while (table[i + rowSpan][columnIndex]) {
						columnIndex++;
					}
					table[i + rowSpan][columnIndex] = cells[j];
				}
				columnIndex++;
			}
		}
	}

	return table;
});

// This was the old name
table.toArray = table.toGrid;

Version data entries

271 entries across 271 versions & 1 rubygems

Version Path
govuk_publishing_components-30.4.1 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-30.4.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-30.3.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-30.2.1 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-30.2.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-30.1.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-30.0.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.15.3 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.15.2 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.15.1 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.15.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.14.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.13.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.12.1 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.12.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.11.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.10.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.9.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.8.0 node_modules/axe-core/lib/commons/table/to-grid.js
govuk_publishing_components-29.7.0 node_modules/axe-core/lib/commons/table/to-grid.js