Skip to content

Commit

Permalink
Merge pull request #1 from squizlabs/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
stefanruijsenaars authored Sep 5, 2020
2 parents bcfcd6a + 78bd10d commit c3e3c19
Show file tree
Hide file tree
Showing 10 changed files with 542 additions and 40 deletions.
9 changes: 5 additions & 4 deletions HTMLCS.Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,17 +1326,18 @@ _global.HTMLCS.util = function() {
} else {
return element.innerText;
}
}
};


/**
* Get the accessible name.
*
* @param {DOMNode} element Element to process.
* @param {DOMNode} element Element to process.
* @param {DOMNode} top Scoped container element.
*
* @returns {String} The accessible name.
*/
self.getAccessibleName = function(element) {
self.getAccessibleName = function(element, top) {
// See https://www.w3.org/TR/accname-1.1/#terminology
if (self.isVisuallyHidden(element)) {
return '';
Expand Down Expand Up @@ -1364,7 +1365,7 @@ _global.HTMLCS.util = function() {
}
// Give up - we only test the 3 most obvious cases.
return "";
}
};

return self;
}();
18 changes: 14 additions & 4 deletions HTMLCS.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,21 @@ _global.HTMLCS = new function()
* @return {String}
*/
this.getTranslation = function(text) {
try {
return _global.translation[this.lang][text];
} catch (e) {
throw new Error('Translation for "' + text + '" does not exist in current language ' + this.lang);
var translations = _global.translation[this.lang];

if (!translations) {
console.error('Missing translations for language ' + this.lang);
return '';
}

var translation = translations[text];

if (!translation) {
console.error('Translation for "' + text + '" does not exist in current language ' + this.lang);
return '';
}

return translation;
};

/**
Expand Down
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Special thanks to:
* [dmassiani](https://github.com/dmassiani) (French Translation)
* [jamadam](https://github.com/jamadam) (Japanese Translation)
* [tassoman](https://github.com/tassoman) (Italian Translation)
* [bdeclerc](https://github.com/bdeclerc) (Dutch Translation)

## License

Expand Down
5 changes: 3 additions & 2 deletions Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_3/1_3_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = {
*/
testSemanticPresentationRole: function(element)
{
var permitted = ['div', 'span', 'b', 'i'];
if (HTMLCS.util.isAriaHidden(element) === false
&& element.hasAttribute('role')
&& element.getAttribute('role') === 'presentation'
&& element.getAttribute('role') === 'presentation'
&& permitted.indexOf(element.nodeName.toLowerCase()) === -1
) {
var permitted = ['div', 'span', 'b', 'i'];
var children = element.querySelectorAll('*:not('+permitted.join('):not(')+')');
children = [].filter.call(children, function(child) {
return child.hasAttribute('role') === false;
Expand Down
10 changes: 6 additions & 4 deletions Standards/WCAG2AAA/Sniffs/Principle2/Guideline2_5/2_5_3.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_5_2_5_3 = {
switch (nodeName) {
case "a":
visibleLabel = HTMLCS.util.getTextContent(element);
accessibleName = HTMLCS.util.getAccessibleName(element);
accessibleName = HTMLCS.util.getAccessibleName(element, top);
break;
case "button":
visibleLabel = HTMLCS.util.getTextContent(element);
accessibleName = HTMLCS.util.getAccessibleName(element);
accessibleName = HTMLCS.util.getAccessibleName(element, top);
break;
case "label":
visibleLabel = HTMLCS.util.getTextContent(element);
Expand All @@ -61,14 +61,16 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_5_2_5_3 = {
} else {
var refNode = top.getElementById(labelFor);
}
accessibleName = HTMLCS.util.getAccessibleName(refNode);
if (refNode) {
accessibleName = HTMLCS.util.getAccessibleName(refNode, top);
}
}
break;
case "input":
if (element.getAttribute("type") === "submit") {
visibleLabel = element.getAttribute("value");
}
accessibleName = HTMLCS.util.getAccessibleName(element);
accessibleName = HTMLCS.util.getAccessibleName(element, top);
break;
}
if (!!visibleLabel && !!accessibleName) {
Expand Down
2 changes: 1 addition & 1 deletion Standards/WCAG2AAA/Sniffs/Principle4/Guideline4_1/4_1_3.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_3 = {
*/
process: function(element, top)
{
HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("4_1_3_ARIA22,G199,ARIA19,G83,G84,G85,G139,G177,G194,ARIA23,ARIA22.Check"), '');
HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("4_1_3_ARIA22,G199,ARIA19,G83,G84,G85,G139,G177,G194,ARIA23.Check"), '');
}
};
7 changes: 1 addition & 6 deletions Tests/WCAG2/1_3_1_Presentation_Roles.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
Name: SC 1.3.1 Presentation Roles
Standard: WCAG2AAA
Assert: No Error *.H37 on #deliberateFail1
Assert: Error *.F92.ARIA4 on #ignoredRole
Assert: No Error *.F92.ARIA4 on #ignoredRole
Assert: No Error *.H37 on #deliberateFail2
Assert: No Error *.F92.ARIA4 on #ariaHidden
Assert: Error *.F92.ARIA4 on #incorrectUsageTable
Assert: No Error *.F92.ARIA4 on #correctUsage
Assert: No Error *.F92.ARIA4 on #correctUsage
Assert: No Error *.F92.ARIA4 on #correctUsageWithRoles
Assert: No Error *.F92.ARIA4 on #incorrectUsageTable2
Assert: No Error *.F92.ARIA4 on #incorrectUsageTable3
Expand All @@ -34,9 +32,6 @@
<th>Row 1 Col 2</th>
</tr>
</table>
<div id="correctUsage" role="presentation">
<span></span>
</div>
<ul role="tree">
<li id="correctUsageWithRoles" role="presentation">
<a role="treeitem" aria-expanded="true">An expanded tree node</a>
Expand Down
27 changes: 13 additions & 14 deletions Translations/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ _global.translation['en'] = {
,"auditor_suggested_techniques" : "Suggested Techniques"
,"auditor_applies_entire_document" : "This applies to the entire document"


//1_1_1.js
,"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.'
,"1_1_1_H67.1" : 'Img element with empty alt text must have absent or empty title attribute.'
Expand Down Expand Up @@ -102,7 +103,7 @@ _global.translation['en'] = {
,"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.'
,"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.'
,"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.'
//{{id}} will be replace with element ID:
//{{id}} will be replaced with element ID:
,"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.'

,"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.'
Expand Down Expand Up @@ -166,15 +167,15 @@ _global.translation['en'] = {


//1_3_5.js
,"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>.'
,"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>'
,"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'
,"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'
,"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'
,"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'
,"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'
,"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'
,"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'
,"1_3_5_H98.FaultyValue" : 'This element contains a potentially faulty value in its autocomplete attribute: {{valuesStr}}.'
,"1_3_5_H98.InvalidAutoComplete_Text" : 'Invalid autocomplete value: {{x}}. Element does not belong to Text control group.'
,"1_3_5_H98.InvalidAutoComplete_Multiline" : 'Invalid autocomplete value: {{x}}. Element does not belong to Multiline control group.'
,"1_3_5_H98.InvalidAutoComplete_Password" : 'Invalid autocomplete value: {{x}}. Element does not belong to Password control group.'
,"1_3_5_H98.InvalidAutoComplete_Url" : 'Invalid autocomplete value: {{x}}. Element does not belong to Url control group.'
,"1_3_5_H98.InvalidAutoComplete_Telephone" : 'Invalid autocomplete value: {{x}}. Element does not belong to Telephone control group.'
,"1_3_5_H98.InvalidAutoComplete_Numeric" : 'Invalid autocomplete value: {{x}}. Element does not belong to Numeric control group.'
,"1_3_5_H98.InvalidAutoComplete_Month" : 'Invalid autocomplete value: {{x}}. Element does not belong to Month control group.'
,"1_3_5_H98.InvalidAutoComplete_Date" : 'Invalid autocomplete value: {{x}}. Element does not belong to Date control group.'
,"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.'
,"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.'

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



//1_4_7.js
,"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.'

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


//1_4_13.js
,"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: \
\
Expand Down Expand Up @@ -509,7 +509,6 @@ _global.translation['en'] = {
,"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.'



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

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


//4_1_3.js
,"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.'
,"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.'

};
Loading

0 comments on commit c3e3c19

Please sign in to comment.