diff --git a/HTMLCS.Util.js b/HTMLCS.Util.js index 1550324e..8381bdc6 100644 --- a/HTMLCS.Util.js +++ b/HTMLCS.Util.js @@ -903,6 +903,8 @@ _global.HTMLCS.util = function() { * - wrongHeaders (Array): Array of elements where headers attr is incorrect. * Each is a structure with following keys: element, * expected [headers attr], actual [headers attr]. + * - isMultiLevelHeadersTable (Boolean): Whether this table has multi-level headers. + * See: https://www.w3.org/WAI/tutorials/tables/multi-level/ * * @param {DOMNode} element Table element to test upon. * @@ -917,7 +919,8 @@ _global.HTMLCS.util = function() { allowScope: true, missingThId: [], missingTd: [], - wrongHeaders: [] + wrongHeaders: [], + isMultiLevelHeadersTable: false, }; var rows = self.getChildrenForTable(element, 'tr'); @@ -1022,6 +1025,7 @@ _global.HTMLCS.util = function() { if ((multiHeaders.rows > 1) || (multiHeaders.cols > 1)) { retval.allowScope = false; + retval.isMultiLevelHeadersTable = true; } else if ((retval.allowScope === true) && ((multiHeaders.rows === 0) || (multiHeaders.cols === 0))) { // If only one column OR one row header. retval.required = false; diff --git a/HTMLCS.js b/HTMLCS.js index 90974d37..0dc354c2 100755 --- a/HTMLCS.js +++ b/HTMLCS.js @@ -84,13 +84,15 @@ _global.HTMLCS = new function() var translations = _global.translation[this.lang]; if (!translations) { - throw new Error ('Missing translations for language ' + this.lang); + console.error('Missing translations for language ' + this.lang); + return ''; } var translation = translations[text]; if (!translation) { - throw new Error('Translation for "' + text + '" does not exist in current language ' + this.lang); + console.error('Translation for "' + text + '" does not exist in current language ' + this.lang); + return ''; } return translation; diff --git a/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js b/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js index be429e10..44e7e665 100755 --- a/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js +++ b/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js @@ -459,9 +459,13 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } }//end if - // Incorrect usage of headers - error; emit always. - for (var i = 0; i < headersAttr.wrongHeaders.length; i++) { - HTMLCS.addMessage(HTMLCS.ERROR, headersAttr.wrongHeaders[i].element, _global.HTMLCS.getTranslation("1_3_1_H43.IncorrectAttr").replace(/\{\{expected\}\}/g, headersAttr.wrongHeaders[i].expected).replace(/\{\{actual\}\}/g, headersAttr.wrongHeaders[i].actual), 'H43.IncorrectAttr'); + if (headersAttr.isMultiLevelHeadersTable) { + HTMLCS.addMessage(HTMLCS.NOTICE, table, _global.HTMLCS.getTranslation("1_3_1_H43.IncorrectAttrNotice"), 'H43.IncorrectAttr'); + } else { + // Incorrect usage of headers - error; emit always. + for (var i = 0; i < headersAttr.wrongHeaders.length; i++) { + HTMLCS.addMessage(HTMLCS.ERROR, headersAttr.wrongHeaders[i].element, _global.HTMLCS.getTranslation("1_3_1_H43.IncorrectAttr").replace(/\{\{expected\}\}/g, headersAttr.wrongHeaders[i].expected).replace(/\{\{actual\}\}/g, headersAttr.wrongHeaders[i].actual), 'H43.IncorrectAttr'); + } } // Errors where headers are compulsory. diff --git a/Tests/WCAG2/1_3_1_Table_Header_Attr.html b/Tests/WCAG2/1_3_1_Table_Header_Attr.html index 35fa62be..a2d403f4 100644 --- a/Tests/WCAG2/1_3_1_Table_Header_Attr.html +++ b/Tests/WCAG2/1_3_1_Table_Header_Attr.html @@ -13,6 +13,7 @@ Assert: No Error *.H43.MissingHeadersAttrs on #correctTableHeadersComplexRowspan Assert: No Error *.H63.1 on #correctTableHeadersComplexRowspan Assert: No Error *.H43,H63 on #correctTableHeadersComplexRowspan +Assert: No Error *.H43.IncorrectAttr on #multiHeaders --> @@ -108,5 +109,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Supplier contacts +
 Example 1 LtdExample 2 Co
ContactJames PhillipsMarie Beauchamp
PositionSales DirectorSales Manager
Emailjp@1ltd.example.commarie@2co.example.com
 Example 3 LtdExample 4 Inc
ContactSuzette JonesAlex Howe
PositionSales OfficerSales Director
EmailSuz@ltd3.example.comhowe@4inc.example.com
\ No newline at end of file diff --git a/Translations/cn.js b/Translations/cn.js index 6f1c90e4..5356015c 100644 --- a/Translations/cn.js +++ b/Translations/cn.js @@ -106,6 +106,7 @@ _global.translation['cn'] = { ,"1_3_1_H63.2" : 'td元素上作为其他元素标题的作用域属性在HTML5中已经过时了。使用th元素代替。' ,"1_3_1_H43.ScopeAmbiguous" : '元素的作用域属性在具有多级标题的表中是不明确的。在td元素上使用headers属性。' ,"1_3_1_H43.IncorrectAttr" : '此td元素上不正确的headers属性。期望的“{{expected}}”,但发现“{{actual}}”' + ,"1_3_1_H43.IncorrectAttrNotice" : 'Check that headers attribute on td element is correct.' ,"1_3_1_H43.HeadersRequired" : 'td元素与其关联的th元素之间的关系没有定义。由于该表有多个层次的th元素,因此必须在td元素上使用headers属性。' ,"1_3_1_H43.MissingHeaderIds" : '并非该表中的所有th元素都包含id属性。这些单元格应该包含id,以便td元素的header属性可以引用它们。' ,"1_3_1_H43.MissingHeadersAttrs" : '并非此表中的所有td元素都包含header属性。每个headers属性应该列出与该单元格关联的所有th元素的id。' diff --git a/Translations/en.js b/Translations/en.js index 1c6574d4..7cb27759 100644 --- a/Translations/en.js +++ b/Translations/en.js @@ -121,6 +121,7 @@ _global.translation['en'] = { ,"1_3_1_H63.2" : 'Scope attributes on td elements that act as headings for other elements are obsolete in HTML5. Use a th element instead.' ,"1_3_1_H43.ScopeAmbiguous" : 'Scope attributes on th elements are ambiguous in a table with multiple levels of headings. Use the headers attribute on td elements instead.' ,"1_3_1_H43.IncorrectAttr" : 'Incorrect headers attribute on this td element. Expected "{{expected}}" but found "{{actual}}"' + ,"1_3_1_H43.IncorrectAttrNotice" : 'Check that headers attribute on td elements are correct.' ,"1_3_1_H43.HeadersRequired" : 'The relationship between td elements and their associated th elements is not defined. As this table has multiple levels of th elements, you must use the headers attribute on td elements.' ,"1_3_1_H43.MissingHeaderIds" : 'Not all th elements in this table contain an id attribute. These cells should contain ids so that they may be referenced by td elements\' headers attributes.' diff --git a/Translations/fr.js b/Translations/fr.js index 94742260..f9e2b1fc 100644 --- a/Translations/fr.js +++ b/Translations/fr.js @@ -120,6 +120,7 @@ _global.translation['fr'] = { ,"1_3_1_H63.2" : 'Les attributs Scope sur les éléments td qui servent de titres pour d\'autres éléments sont obsolètes dans HTML5. Utilisez un th élément à la place.' ,"1_3_1_H43.ScopeAmbiguous" : 'Les attributs de portée sur ces éléments sont ambigus dans un tableau à niveaux multiples d\'en-têtes. Utilisez plutôt l\'attribut headers sur les éléments td.' ,"1_3_1_H43.IncorrectAttr" : 'L\'attribut d\'en-tête incorrect sur cet élément td. Attendue "{{expected}}" mais trouvée "{{actual}}".' + ,"1_3_1_H43.IncorrectAttrNotice" : 'Check that headers attribute on td element is correct.' ,"1_3_1_H43.HeadersRequired" : 'La relation entre les éléments td et leurs éléments associés n\'est pas définie. Comme cette table a plusieurs niveaux de ces éléments, vous devez utiliser l\'attribut headers sur les éléments td.' ,"1_3_1_H43.MissingHeaderIds" : 'Tous les éléments de cette table ne contiennent pas un attribut id. Ces cellules devraient contenir des ids de sorte qu\'elles puissent être référencées par des éléments td attributs d\'en-têtes.' diff --git a/Translations/it.js b/Translations/it.js index cdd0cb38..443cda34 100644 --- a/Translations/it.js +++ b/Translations/it.js @@ -120,6 +120,7 @@ _global.translation['it'] = { ,"1_3_1_H63.2" : 'Scope attributes on td elements that act as headings for other elements are obsolete in HTML5. Use a th element instead.' ,"1_3_1_H43.ScopeAmbiguous" : 'Scope attributes on th elements are ambiguous in a table with multiple levels of headings. Use the headers attribute on td elements instead.' ,"1_3_1_H43.IncorrectAttr" : 'Incorrect headers attribute on this td element. Expected "{{expected}}" but found "{{actual}}"' + ,"1_3_1_H43.IncorrectAttrNotice" : 'Check that headers attribute on td element is correct.' ,"1_3_1_H43.HeadersRequired" : 'The relationship between td elements and their associated th elements is not defined. As this table has multiple levels of th elements, you must use the headers attribute on td elements.' ,"1_3_1_H43.MissingHeaderIds" : 'Not all th elements in this table contain an id attribute. These cells should contain ids so that they may be referenced by td elements\' headers attributes.' diff --git a/Translations/ja.js b/Translations/ja.js index fe1c5032..8bd640a5 100644 --- a/Translations/ja.js +++ b/Translations/ja.js @@ -120,6 +120,7 @@ _global.translation['ja'] = { ,"1_3_1_H63.2" : '他の要素の見出しとして機能する td 要素のスコープ属性は、HTML5では廃止されました。代わりに th 要素を使用してください。' ,"1_3_1_H43.ScopeAmbiguous" : '複数のレベルの見出しを持つテーブルでは、 th 要素のスコープ属性はあいまいです。代わりに td 要素の headers 属性を使用してください。' ,"1_3_1_H43.IncorrectAttr" : 'この td 要素のヘッダー属性が正しくありません。 "{{expected}}" を予期していましたが、 "{{actual}}" を検出しました' + ,"1_3_1_H43.IncorrectAttrNotice" : 'Check that headers attribute on td element is correct.' ,"1_3_1_H43.HeadersRequired" : 'td 要素とそれに関連する th 要素の関係は定義されていません。このテーブルには複数レベルの th 要素があるため、 td 要素には headers 属性を使用する必要があります。' ,"1_3_1_H43.MissingHeaderIds" : 'このテーブルに id 属性を含まない th 要素があります。これらのセルは、それらが td 要素の headers 属性によって参照されるように ID を含むべきです。' diff --git a/Translations/nl.js b/Translations/nl.js index bcc110ba..32aaff11 100644 --- a/Translations/nl.js +++ b/Translations/nl.js @@ -120,6 +120,7 @@ _global.translation['nl'] = { ,"1_3_1_H63.2" : 'Scope attributen op td elementen die als hoofdingen gebruikt worden voor andere elementen zijn vervallen in HTML. Gebruik in plaats daarvan een th element.' ,"1_3_1_H43.ScopeAmbiguous" : 'Scope attributen op th elementen zijn ambigu in een tabel met meerdere niveaus van hoofding. Gebruik in plaats daarvan het headers attribuut op td elementen.' ,"1_3_1_H43.IncorrectAttr" : 'Foutief headers attribuut op dit td element. \"{{expected}}\" werd verwacht maar \"{{actual}}\" gevonden' + ,"1_3_1_H43.IncorrectAttrNotice" : 'Check that headers attribute on td element is correct.' ,"1_3_1_H43.HeadersRequired" : 'De relatie tussen td elementen en de eraan gebonden th elementen werd niet omschreven. Gezien deze tabel meerdere niveaus th elmenten bevat, moet het headers attribuut gebruikt worden op td elementen.' ,"1_3_1_H43.MissingHeaderIds" : 'Niet alle th elementen in deze tabel hebben een id attribuut. Deze cellen zouden ids moeten bevatten zodat er kan naar verwezen worden in het headers attribuut van td elementen.' diff --git a/Translations/pl.js b/Translations/pl.js index 926068dc..273afb2d 100755 --- a/Translations/pl.js +++ b/Translations/pl.js @@ -120,6 +120,7 @@ _global.translation['pl'] = { ,"1_3_1_H63.2" : 'Atrybuty scope używane na komórkach tabeli () aby oznaczyć nagłówek są przestarzałe w HTML5. Zaleca się skorzystanie ze znacznika .' ,"1_3_1_H43.ScopeAmbiguous" : 'Użycie atrybutów scope na elementach th jest niejasne w tabeli z wieloma nagłówkami. Rekomenduje się użycie atrybutu "headers" w znaczniku .' ,"1_3_1_H43.IncorrectAttr" : 'Nieprawidłowy atrybut nagłówka w znaczniku . Zamiast "{{actual}}" powinien być "{{expected}}".' + ,"1_3_1_H43.IncorrectAttrNotice" : 'Check that headers attribute on td element is correct.' ,"1_3_1_H43.HeadersRequired" : 'Nie zdefiniowano relacji pomiędzy komórką a powiązanym z nią nagłówkiem . Wskazana tabela ma wiele poziomów , zatem należałoby użyć atrybutu "headers" w komórkach .' ,"1_3_1_H43.MissingHeaderIds" : 'Nie wszystkie nagłówki th w tej tabeli posiadają atrybut "id" i nie będzie się można do nich odwołać za pomocą atrybutu "headers" w znacznikach .'