blob: fdb2c421be6dd820545c2b3785e7c91350d0619b (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/**
* Provide equivalent alternatives to auditory and visual content
*/
exports.name = "Equivalent Alternatives";
exports.description = "";
exports.rule = function(report) {
/* 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);
}
};
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
/* Checkpoint 1.5 [Priority 3] **********************************************/
};
|