aboutsummaryrefslogtreecommitdiff
path: root/guidelines/accessibility/guideline-1.js
blob: 35b3d8907d62b726cab2a5e92584c620dbb89acb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * Provide equivalent alternatives to auditory and visual content
 */

exports.name        = "Equivalent Alternatives";
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);
      }
    };
  };

  // We treat anchors with images as a child as things that should contain
  // alternatives.
  $5('a').find('img').each(hasAlt('img'));

  // 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'));

  // All object tags must have an alt attribute.
  $5('object').each(hasAlt('applet'));
};