From 2e6d0ca2638f34ffb96b0f5bf98e6545b8abefbb Mon Sep 17 00:00:00 2001 From: Benjamin Jones Date: Tue, 16 Jul 2013 17:42:02 -0700 Subject: refactoring --- guidelines/WCAG-1.0/guideline-5.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'guidelines') diff --git a/guidelines/WCAG-1.0/guideline-5.js b/guidelines/WCAG-1.0/guideline-5.js index 48feb49..c8decd7 100644 --- a/guidelines/WCAG-1.0/guideline-5.js +++ b/guidelines/WCAG-1.0/guideline-5.js @@ -7,28 +7,32 @@ exports.rule = function(report) { * For data tables, identify row and column headers. */ - $('table').each(function () { - if ($(this).find('th').length == 0) { - report.error('Table does not have column headers ', this); - } + $5('table').noSubElt('th').each(function () { + report.error('Table does not have column headers ', this); }); - /* Checkpoint 5.5 *********************************************************** * * Provide summaries for tables. */ - $('table').each(function () { - var $cap = $(this).find('caption'); - var title = $.trim($(this).attr('title')); - var sum = $.trim($(this).attr('summary')); - if ($cap.length == 0 && (title === undefined || title == '')) { - report.error('Table has no caption or title attribute', this); - } - if (sum === undefined || sum == '') { - report.error('Table has no summary attribute', this); - } + $5('table').noSubElt('caption') + .noAttr('title') + .each(function () { + report.warning('Table has no caption or title attribute', this); + }); + + $('table').noAttr('summary').each(function () { + report.warning('Table has no summary attribute', this); + }); + + /* Checkpoint 5.6 *********************************************************** + * + * Provide `abbr` attributes to table headers + */ + + $5('th').noAttr('abbr').each(function () { + report.advisory(' has no abbrevation attribute', this); }); }; -- cgit v1.2.3