Skip to content

Commit c3e3c19

Browse files
Merge pull request #1 from squizlabs/master
Update
2 parents bcfcd6a + 78bd10d commit c3e3c19

File tree

10 files changed

+542
-40
lines changed

10 files changed

+542
-40
lines changed

HTMLCS.Util.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,17 +1326,18 @@ _global.HTMLCS.util = function() {
13261326
} else {
13271327
return element.innerText;
13281328
}
1329-
}
1329+
};
13301330

13311331

13321332
/**
13331333
* Get the accessible name.
13341334
*
1335-
* @param {DOMNode} element Element to process.
1335+
* @param {DOMNode} element Element to process.
1336+
* @param {DOMNode} top Scoped container element.
13361337
*
13371338
* @returns {String} The accessible name.
13381339
*/
1339-
self.getAccessibleName = function(element) {
1340+
self.getAccessibleName = function(element, top) {
13401341
// See https://www.w3.org/TR/accname-1.1/#terminology
13411342
if (self.isVisuallyHidden(element)) {
13421343
return '';
@@ -1364,7 +1365,7 @@ _global.HTMLCS.util = function() {
13641365
}
13651366
// Give up - we only test the 3 most obvious cases.
13661367
return "";
1367-
}
1368+
};
13681369

13691370
return self;
13701371
}();

HTMLCS.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,21 @@ _global.HTMLCS = new function()
8181
* @return {String}
8282
*/
8383
this.getTranslation = function(text) {
84-
try {
85-
return _global.translation[this.lang][text];
86-
} catch (e) {
87-
throw new Error('Translation for "' + text + '" does not exist in current language ' + this.lang);
84+
var translations = _global.translation[this.lang];
85+
86+
if (!translations) {
87+
console.error('Missing translations for language ' + this.lang);
88+
return '';
8889
}
90+
91+
var translation = translations[text];
92+
93+
if (!translation) {
94+
console.error('Translation for "' + text + '" does not exist in current language ' + this.lang);
95+
return '';
96+
}
97+
98+
return translation;
8999
};
90100

91101
/**

README.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ Special thanks to:
188188
* [dmassiani](https://github.com/dmassiani) (French Translation)
189189
* [jamadam](https://github.com/jamadam) (Japanese Translation)
190190
* [tassoman](https://github.com/tassoman) (Italian Translation)
191+
* [bdeclerc](https://github.com/bdeclerc) (Dutch Translation)
191192

192193
## License
193194

Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = {
103103
*/
104104
testSemanticPresentationRole: function(element)
105105
{
106+
var permitted = ['div', 'span', 'b', 'i'];
106107
if (HTMLCS.util.isAriaHidden(element) === false
107108
&& element.hasAttribute('role')
108-
&& element.getAttribute('role') === 'presentation'
109+
&& element.getAttribute('role') === 'presentation'
110+
&& permitted.indexOf(element.nodeName.toLowerCase()) === -1
109111
) {
110-
var permitted = ['div', 'span', 'b', 'i'];
111112
var children = element.querySelectorAll('*:not('+permitted.join('):not(')+')');
112113
children = [].filter.call(children, function(child) {
113114
return child.hasAttribute('role') === false;

Standards/WCAG2AAA/Sniffs/Principle2/Guideline2_5/2_5_3.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_5_2_5_3 = {
4646
switch (nodeName) {
4747
case "a":
4848
visibleLabel = HTMLCS.util.getTextContent(element);
49-
accessibleName = HTMLCS.util.getAccessibleName(element);
49+
accessibleName = HTMLCS.util.getAccessibleName(element, top);
5050
break;
5151
case "button":
5252
visibleLabel = HTMLCS.util.getTextContent(element);
53-
accessibleName = HTMLCS.util.getAccessibleName(element);
53+
accessibleName = HTMLCS.util.getAccessibleName(element, top);
5454
break;
5555
case "label":
5656
visibleLabel = HTMLCS.util.getTextContent(element);
@@ -61,14 +61,16 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_5_2_5_3 = {
6161
} else {
6262
var refNode = top.getElementById(labelFor);
6363
}
64-
accessibleName = HTMLCS.util.getAccessibleName(refNode);
64+
if (refNode) {
65+
accessibleName = HTMLCS.util.getAccessibleName(refNode, top);
66+
}
6567
}
6668
break;
6769
case "input":
6870
if (element.getAttribute("type") === "submit") {
6971
visibleLabel = element.getAttribute("value");
7072
}
71-
accessibleName = HTMLCS.util.getAccessibleName(element);
73+
accessibleName = HTMLCS.util.getAccessibleName(element, top);
7274
break;
7375
}
7476
if (!!visibleLabel && !!accessibleName) {

Standards/WCAG2AAA/Sniffs/Principle4/Guideline4_1/4_1_3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_3 = {
3434
*/
3535
process: function(element, top)
3636
{
37-
HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("4_1_3_ARIA22,G199,ARIA19,G83,G84,G85,G139,G177,G194,ARIA23,ARIA22.Check"), '');
37+
HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("4_1_3_ARIA22,G199,ARIA19,G83,G84,G85,G139,G177,G194,ARIA23.Check"), '');
3838
}
3939
};

Tests/WCAG2/1_3_1_Presentation_Roles.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
Name: SC 1.3.1 Presentation Roles
77
Standard: WCAG2AAA
88
Assert: No Error *.H37 on #deliberateFail1
9-
Assert: Error *.F92.ARIA4 on #ignoredRole
9+
Assert: No Error *.F92.ARIA4 on #ignoredRole
1010
Assert: No Error *.H37 on #deliberateFail2
1111
Assert: No Error *.F92.ARIA4 on #ariaHidden
1212
Assert: Error *.F92.ARIA4 on #incorrectUsageTable
13-
Assert: No Error *.F92.ARIA4 on #correctUsage
14-
Assert: No Error *.F92.ARIA4 on #correctUsage
1513
Assert: No Error *.F92.ARIA4 on #correctUsageWithRoles
1614
Assert: No Error *.F92.ARIA4 on #incorrectUsageTable2
1715
Assert: No Error *.F92.ARIA4 on #incorrectUsageTable3
@@ -34,9 +32,6 @@
3432
<th>Row 1 Col 2</th>
3533
</tr>
3634
</table>
37-
<div id="correctUsage" role="presentation">
38-
<span></span>
39-
</div>
4035
<ul role="tree">
4136
<li id="correctUsageWithRoles" role="presentation">
4237
<a role="treeitem" aria-expanded="true">An expanded tree node</a>

Translations/en.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ _global.translation['en'] = {
3737
,"auditor_suggested_techniques" : "Suggested Techniques"
3838
,"auditor_applies_entire_document" : "This applies to the entire document"
3939

40+
4041
//1_1_1.js
4142
,"1_1_1_H30.2" : 'Img element is the only content of the link, but is missing alt text. The alt text should describe the purpose of the link.'
4243
,"1_1_1_H67.1" : 'Img element with empty alt text must have absent or empty title attribute.'
@@ -102,7 +103,7 @@ _global.translation['en'] = {
102103
,"1_3_1_H44.NotFormControl" : 'This label\'s "for" attribute contains an ID for an element that is not a form control. Ensure that you have entered the correct ID for the intended element.'
103104
,"1_3_1_H65" : 'This form control has a "title" attribute that is empty or contains only spaces. It will be ignored for labelling test purposes.'
104105
,"1_3_1_ARIA6" : 'This form control has an "aria-label" attribute that is empty or contains only spaces. It will be ignored for labelling test purposes.'
105-
//{{id}} will be replace with element ID:
106+
//{{id}} will be replaced with element ID:
106107
,"1_3_1_ARIA16,ARIA9" : 'This form control contains an aria-labelledby attribute, however it includes an ID "{{id}}" that does not exist on an element. The aria-labelledby attribute will be ignored for labelling test purposes.'
107108

108109
,"1_3_1_F68.Hidden" : 'This hidden form field is labelled in some way. There should be no need to label a hidden form field.'
@@ -166,15 +167,15 @@ _global.translation['en'] = {
166167

167168

168169
//1_3_5.js
169-
,"1_3_5_H98.FaultyValue" : 'This element contains a potentially faulty value in its autocomplete attribute: {{valuesStr}}. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute</a>.'
170-
,"1_3_5_H98.InvalidAutocomplete_Text" : 'Invalid autocomplete value: {{x}}. Element does not belong to Text control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute</a>'
171-
,"1_3_5_H98.InvalidAutocomplete_Multiline" : 'Invalid autocomplete value: {{x}}. Element does not belong to Multiline control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute'
172-
,"1_3_5_H98.InvalidAutocomplete_Password" : 'Invalid autocomplete value: {{x}}. Element does not belong to Password control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute'
173-
,"1_3_5_H98.InvalidAutocomplete_Url" : 'Invalid autocomplete value: {{x}}. Element does not belong to Url control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute'
174-
,"1_3_5_H98.InvalidAutocomplete_Telephone" : 'Invalid autocomplete value: {{x}}. Element does not belong to Telephone control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute'
175-
,"1_3_5_H98.InvalidAutocomplete_Numeric" : 'Invalid autocomplete value: {{x}}. Element does not belong to Numeric control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute'
176-
,"1_3_5_H98.InvalidAutocomplete_Month" : 'Invalid autocomplete value: {{x}}. Element does not belong to Month control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute'
177-
,"1_3_5_H98.InvalidAutocomplete_Date" : 'Invalid autocomplete value: {{x}}. Element does not belong to Date control group. See https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute'
170+
,"1_3_5_H98.FaultyValue" : 'This element contains a potentially faulty value in its autocomplete attribute: {{valuesStr}}.'
171+
,"1_3_5_H98.InvalidAutoComplete_Text" : 'Invalid autocomplete value: {{x}}. Element does not belong to Text control group.'
172+
,"1_3_5_H98.InvalidAutoComplete_Multiline" : 'Invalid autocomplete value: {{x}}. Element does not belong to Multiline control group.'
173+
,"1_3_5_H98.InvalidAutoComplete_Password" : 'Invalid autocomplete value: {{x}}. Element does not belong to Password control group.'
174+
,"1_3_5_H98.InvalidAutoComplete_Url" : 'Invalid autocomplete value: {{x}}. Element does not belong to Url control group.'
175+
,"1_3_5_H98.InvalidAutoComplete_Telephone" : 'Invalid autocomplete value: {{x}}. Element does not belong to Telephone control group.'
176+
,"1_3_5_H98.InvalidAutoComplete_Numeric" : 'Invalid autocomplete value: {{x}}. Element does not belong to Numeric control group.'
177+
,"1_3_5_H98.InvalidAutoComplete_Month" : 'Invalid autocomplete value: {{x}}. Element does not belong to Month control group.'
178+
,"1_3_5_H98.InvalidAutoComplete_Date" : 'Invalid autocomplete value: {{x}}. Element does not belong to Date control group.'
178179
,"1_3_5_H98.Purpose" : 'Check that the input field serves a purpose identified in the Input Purposes for User Interface Components section; and that the content is implemented using technologies with support for identifying the expected meaning for form input data.'
179180
,"1_3_5_H98.MissingAutocomplete" : 'This element does not have an autocomplete attribute. If this field collects information about the user, consider adding one to comply with this Success Criterion.'
180181

@@ -223,7 +224,6 @@ _global.translation['en'] = {
223224
,"1_4_6_G18_or_G17.Fail.Recomendation.Background" : 'change background to {{value}}'
224225

225226

226-
227227
//1_4_7.js
228228
,"1_4_7_G56" : 'For pre-recorded audio-only content in this element that is primarily speech (such as narration), any background sounds should be muteable, or be at least 20 dB (or about 4 times) quieter than the speech.'
229229

@@ -264,7 +264,7 @@ _global.translation['en'] = {
264264
Letter spacing (tracking) to at least 0.12 times the font size; \
265265
Word spacing to at least 0.16 times the font size.'
266266

267-
267+
268268
//1_4_13.js
269269
,"1_4_13_F95.Check" : 'Check that where receiving and then removing pointer hover or keyboard focus triggers additional content to become visible and then hidden, the following are true: \
270270
\
@@ -509,7 +509,6 @@ _global.translation['en'] = {
509509
,"3_3_6_G98,G99,G155,G164,G168.AllForms" : 'Check that submissions to this form are either reversible, checked for input errors, and/or confirmed by the user.'
510510

511511

512-
513512
//4_1_1.js
514513
,"4_1_1_F77" : 'Duplicate id attribute value "{{id}}" found on the web page.'
515514

@@ -536,6 +535,6 @@ _global.translation['en'] = {
536535

537536

538537
//4_1_3.js
539-
,"4_1_3_ARIA22,G199,ARIA19,G83,G84,G85,G139,G177,G194,ARIA23,ARIA22.Check" : 'Check that status messages can be programmatically determined through role or properties such that they can be presented to the user by assistive technologies without receiving focus.'
538+
,"4_1_3_ARIA22,G199,ARIA19,G83,G84,G85,G139,G177,G194,ARIA23.Check" : 'Check that status messages can be programmatically determined through role or properties such that they can be presented to the user by assistive technologies without receiving focus.'
540539

541540
};

0 commit comments

Comments
 (0)