aboutsummaryrefslogtreecommitdiff
path: root/ruleSets/basicUIRules.json
blob: 727ff8bebd7b69ba865969b0dba7aec59ecd1f08 (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
{ 'name': "Basic HTML guidelines."
, 'description': "A selection of simple HTML guidelines for improved usability and consistency."
, 'rules': [ { 'name': "All input fields have exactly one label."
             , 'description': "<p>Screen readers rely on HTML attributes to identify the purpose "
                              + "of form widgets on-screen.  These tools use label tags with 'for' "
                              + "attributes that specify the id of the form element they pertain to. "
                              + "Some of the components of this web page do not have those labels.</p>"
             , 'rule':
               function() {
                 fiveui.query(':input').each(
                   function(i, elt) {
                     if (elt.id) {
                       var $label = fiveui.query("label[for='"+elt.id+"']");

                       if (1 < $label.size()) {
                         report('Form element has too many labels', elt);
                       }

                       if (0 == $label.size()) {
                         report('Form element has no label', elt);
                       }
                     }
                   });
               }
             },
             { 'name': "Don't use empty headings."
             , 'description': "Empty headings confuse layout."
             , 'rule':
               function() {
                 fiveui.query(':header').each(
                    function(i, elt) {
                      if ($(elt).text() == '') {
                        report('Heading is empty', elt);
                      }
                    });
               }
             },
             { 'name': "Don't use empty hrefs."
             , 'description': "Links with no text can't generally be used."
             , 'rule':
               function() {
                 fiveui.query('a').each(
                    function(i, elt) {
                      if ($(elt).text() == '' && elt.title == '') {
                        report('Link has no text', elt);
                      }
                    });
               }
             }
           ]
}