aboutsummaryrefslogtreecommitdiff
path: root/guidelines
diff options
context:
space:
mode:
authorGravatar Trevor Elliott <trevor@galois.com>2013-06-24 15:23:02 -0700
committerGravatar Trevor Elliott <trevor@galois.com>2013-06-24 15:23:02 -0700
commit50e042c8981608e4121f94faec138db0c3e294e3 (patch)
treeff9a6148ecf439f2a7180a13ad10330b5aeeaec5 /guidelines
parent1bf5409ef45872e84f62d2199b918ab233461aed (diff)
Better coverage of checkpoint 1.1 requirements
Diffstat (limited to 'guidelines')
-rw-r--r--guidelines/accessibility/guideline-1.js71
1 files changed, 56 insertions, 15 deletions
diff --git a/guidelines/accessibility/guideline-1.js b/guidelines/accessibility/guideline-1.js
index 35b3d89..fdb2c42 100644
--- a/guidelines/accessibility/guideline-1.js
+++ b/guidelines/accessibility/guideline-1.js
@@ -7,24 +7,65 @@ exports.description = "";
exports.rule = function(report) {
- var hasAlt = function(type) {
- return function(ix) {
- if(_.isEmpty($(this).attr('alt'))) {
- report.error('No alt text specified for ' + type + ' element', this);
- }
- };
+
+ /* Checkpoint 1.1 [Priority 1] **********************************************/
+
+ var hasAlt = function(ix) {
+ // TODO: strip space from the alt attribute to prevent ' ' from passing
+ // the test
+ if(_.isEmpty($(this).attr('alt')) && _.isEmpty($(this).attr('longdesc'))) {
+ report.error('No alt/longdesc specified', this);
+ }
};
- // We treat anchors with images as a child as things that should contain
- // alternatives.
- $5('a').find('img').each(hasAlt('img'));
+ var hasText = function(ix) {
+ // TODO: strip space from the text to prevent ' ' from passing the test
+ if(_.isEmpty($(this).text())) {
+ report.error('No text node', this);
+ }
+ };
+
+ // images with semantic meaning should have an alt attribute.
+ $5('a').find('img')
+ .add($5('dl').find('img'))
+ .add($5('dd').find('img'))
+ .each(hasAlt);
+
+ // All `input` tags must have an alt attribute.
+ $5('input').each(hasAlt);
+
+ // All `applet` tags must have a text node
+ $5('applet').each(hasText);
+
+ // All `object` tags must have a text node
+ $5('object').each(hasText).each(hasAlt);
+
+ // TODO: what's the best way to classify content that's `complex`?
+
+ // All `area` elements of an image map should have alt attributes. This isn't
+ // quite a faithful implementation, as it doesn't take into account the case
+ // where an `a` tag is wrapped around the `area` tag.
+ $5('map').find('area').each(hasAlt);
+
+ // TODO: figure out a good way to handle frames.
+ // TODO: figure out a good way to handle scripts.
+
+
+ /* Checkpoint 1.2 [Priority 1] **********************************************/
+
+ // TODO
+
+
+ /* Checkpoint 1.3 [Priority 1] **********************************************/
+
+ // TODO
+
+
+ /* Checkpoint 1.4 [Priority 1] **********************************************/
+
+ // TODO
- // All input tags must have an alt attribute.
- $5('input').each(hasAlt('input'));
- // All applet tags must have an alt attribute.
- $5('applet').each(hasAlt('applet'));
+ /* Checkpoint 1.5 [Priority 3] **********************************************/
- // All object tags must have an alt attribute.
- $5('object').each(hasAlt('applet'));
};