You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js
+37-8
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,7 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = {
75
75
break;
76
76
77
77
case'table':
78
+
this.testGeneralTable(element);
78
79
this.testTableHeaders(element);
79
80
this.testTableCaptionSummary(element);
80
81
break;
@@ -676,20 +677,32 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = {
676
677
summary=summary.replace(/^\s*(.*?)\s*$/g,'$1');
677
678
678
679
if(summary!==''){
679
-
if(caption===summary){
680
-
HTMLCS.addMessage(HTMLCS.ERROR,table,'If this table is a data table, and both a summary attribute and a caption element are present, the summary should not duplicate the caption.','H39,H73.4');
681
-
}
680
+
if(HTMLCS.util.isLayoutTable(table)===true){
681
+
HTMLCS.addMessage(HTMLCS.ERROR,table,'This table appears to be used for layout, but contains a summary attribute. Layout tables must not contain summary attributes, or if supplied, must be empty.','H73.3.LayoutTable');
682
+
}else{
683
+
if(caption===summary){
684
+
HTMLCS.addMessage(HTMLCS.ERROR,table,'If this table is a data table, and both a summary attribute and a caption element are present, the summary should not duplicate the caption.','H39,H73.4');
685
+
}
682
686
683
-
HTMLCS.addMessage(HTMLCS.NOTICE,table,'If this table is a data table, check that the summary attribute describes the table\'s organization or explains how to use the table.','H73.3.Check');
687
+
HTMLCS.addMessage(HTMLCS.NOTICE,table,'If this table is a data table, check that the summary attribute describes the table\'s organization or explains how to use the table.','H73.3.Check');
688
+
}
684
689
}else{
685
-
HTMLCS.addMessage(HTMLCS.WARNING,table,'If this table is a data table, consider using the summary attribute of the table element to give an overview of this table.','H73.3.NoSummary');
690
+
if(HTMLCS.util.isLayoutTable(table)===false){
691
+
HTMLCS.addMessage(HTMLCS.WARNING,table,'If this table is a data table, consider using the summary attribute of the table element to give an overview of this table.','H73.3.NoSummary');
692
+
}
686
693
}//end if
687
694
688
695
if(caption!==''){
689
-
HTMLCS.addMessage(HTMLCS.NOTICE,table,'If this table is a data table, check that the caption element accurately describes this table.','H39.3.Check');
696
+
if(HTMLCS.util.isLayoutTable(table)===true){
697
+
HTMLCS.addMessage(HTMLCS.ERROR,table,'This table appears to be used for layout, but contains a caption element. Layout tables must not contain captions.','H39.3.LayoutTable');
698
+
}else{
699
+
HTMLCS.addMessage(HTMLCS.NOTICE,table,'If this table is a data table, check that the caption element accurately describes this table.','H39.3.Check');
700
+
}
690
701
}else{
691
-
HTMLCS.addMessage(HTMLCS.WARNING,table,'If this table is a data table, consider using a caption element to the table element to identify this table.','H39.3.NoCaption');
692
-
}
702
+
if(HTMLCS.util.isLayoutTable(table)===false){
703
+
HTMLCS.addMessage(HTMLCS.WARNING,table,'If this table is a data table, consider using a caption element to the table element to identify this table.','H39.3.NoCaption');
704
+
}
705
+
}//end if
693
706
},
694
707
695
708
/**
@@ -900,5 +913,21 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = {
900
913
HTMLCS.addMessage(HTMLCS.WARNING,element,'If this element contains a navigation section, it is recommended that it be marked up as a list.','H48');
901
914
}
902
915
}//end if
916
+
},
917
+
918
+
/**
919
+
* Provide generic messages for tables depending on what type of table they
920
+
* are - layout or data.
921
+
*
922
+
* @param {DOMNode} table The table element to test.
923
+
*
924
+
* @returns void
925
+
*/
926
+
testGeneralTable: function(table){
927
+
if(HTMLCS.util.isLayoutTable(table)===true){
928
+
HTMLCS.addMessage(HTMLCS.NOTICE,table,'This table appears to be a layout table. If it is meant to instead be a data table, ensure header cells are identified using th elements.','LayoutTable');
929
+
}else{
930
+
HTMLCS.addMessage(HTMLCS.NOTICE,table,'This table appears to be a data table. If it is meant to instead be a layout table, ensure there are no th elements, and no summary or caption.','DataTable');
0 commit comments