Skip to content

Commit 41c355b

Browse files
committed
Merge branch 'stefanruijsenaars-master'
2 parents a278180 + d00498a commit 41c355b

25 files changed

Lines changed: 1587 additions & 82 deletions

File tree

HTMLCS.Util.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,5 +1312,59 @@ _global.HTMLCS.util = function() {
13121312
return nextNode;
13131313
};
13141314

1315+
1316+
/**
1317+
* Get the text content of a DOM node.
1318+
*
1319+
* @param {DOMNode} element Element to process.
1320+
*
1321+
* @returns {String} The text content.
1322+
*/
1323+
self.getTextContent = function(element) {
1324+
if (element.textContent !== undefined) {
1325+
return element.textContent;
1326+
} else {
1327+
return element.innerText;
1328+
}
1329+
};
1330+
1331+
1332+
/**
1333+
* Get the accessible name.
1334+
*
1335+
* @param {DOMNode} element Element to process.
1336+
*
1337+
* @returns {String} The accessible name.
1338+
*/
1339+
self.getAccessibleName = function(element) {
1340+
// See https://www.w3.org/TR/accname-1.1/#terminology
1341+
if (self.isVisuallyHidden(element)) {
1342+
return '';
1343+
}
1344+
else if (element.getAttribute("aria-labelledby")) {
1345+
var nameParts = [];
1346+
var parts = element.getAttribute("aria-labelledby").split(" ");
1347+
for (var i = 0; i < parts.length; i++) {
1348+
var x = parts[i];
1349+
var nameElement = top.getElementById(x);
1350+
if (nameElement) {
1351+
nameParts.push(nameElement.textContent);
1352+
}
1353+
}
1354+
return nameParts.join(" ");
1355+
} else if (element.getAttribute("aria-label")) {
1356+
return element.getAttribute("aria-label");
1357+
} else if (element.getAttribute("title")) {
1358+
if (
1359+
element.getAttribute("role") !== "presentation" &&
1360+
element.getAttribute("role") !== "none"
1361+
) {
1362+
return element.getAttribute("aria-label");
1363+
}
1364+
}
1365+
// Give up - we only test the 3 most obvious cases.
1366+
return "";
1367+
};
1368+
13151369
return self;
13161370
}();

README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
HTML_CodeSniffer is a JavaScript application that checks a HTML document
66
or source code, and detects violations of a defined presentation or accessibility
7-
standard, such as Section508 or WCAG2.0.
7+
standard, such as Section508 or WCAG2.1.
88

99
## Standards included
1010

1111
By default, HTML_CodeSniffer comes with standards that cover the three conformance
12-
levels of the <abbr title="World Wide Web Consortium">W3C</abbr> [Web Content Accessibility Guidelines (WCAG) 2.0](http://www.w3.org/TR/WCAG20),
12+
levels of the <abbr title="World Wide Web Consortium">W3C</abbr> [Web Content Accessibility Guidelines (WCAG) 2.1](https://www.w3.org/TR/WCAG21/),
1313
and the <abbr title="United States of America">U.S.</abbr> [Section 508](http://section508.gov/index.cfm?fuseAction=stdsdoc) legislation.
1414
It also provides tools to write your own standards, which can be useful in situations
1515
where you wish to enforce consistency across a web site.

Standards/Section508/Sniffs/A.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ _global.HTMLCS_Section508_Sniffs_A = {
4848
if ((nodeName === 'object') || (nodeName === 'bgsound') || (nodeName === 'audio')) {
4949
// Audio transcript notice. Yes, this is in A rather than B, since
5050
// audio is not considered "multimedia" (roughly equivalent to a
51-
// "synchronised media" presentation in WCAG 2.0). It is non-text,
51+
// "synchronised media" presentation in WCAG 2.1). It is non-text,
5252
// though, so a transcript is required.
5353
HTMLCS.addMessage(HTMLCS.NOTICE, element, 'For multimedia containing audio only, ensure an alternative is available, such as a full text transcript.', 'Audio');
5454
}
@@ -177,7 +177,7 @@ _global.HTMLCS_Section508_Sniffs_A = {
177177
* Driver function for the null alt text tests.
178178
*
179179
* This takes the generic result given by the alt text testing functions
180-
* (located in WCAG 2.0 SC 1.1.1), and converts them into Section 508-specific
180+
* (located in WCAG 2.1 SC 1.1.1), and converts them into Section 508-specific
181181
* messages.
182182
*
183183
* @param {DOMNode} element The element to test.
@@ -293,7 +293,7 @@ _global.HTMLCS_Section508_Sniffs_A = {
293293
* Driver function for the media alternative (object/applet) tests.
294294
*
295295
* This takes the generic result given by the media alternative testing function
296-
* (located in WCAG 2.0 SC 1.1.1), and converts them into Section
296+
* (located in WCAG 2.1 SC 1.1.1), and converts them into Section
297297
* 508-specific messages.
298298
*
299299
* @param {DOMNode} element The element to test.

Standards/WCAG2A/ruleset.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
_global.HTMLCS_WCAG2A = {
1515
name: 'WCAG2A',
16-
description: 'Web Content Accessibility Guidelines (WCAG) 2.0 A',
16+
description: 'Web Content Accessibility Guidelines (WCAG) 2.1 A',
1717
sniffs: [
1818
{
1919
standard: 'WCAG2AAA',
@@ -30,13 +30,18 @@ _global.HTMLCS_WCAG2A = {
3030
'Principle1.Guideline1_4.1_4_2',
3131
'Principle2.Guideline2_1.2_1_1',
3232
'Principle2.Guideline2_1.2_1_2',
33+
'Principle2.Guideline2_1.2_1_4',
3334
'Principle2.Guideline2_2.2_2_1',
3435
'Principle2.Guideline2_2.2_2_2',
3536
'Principle2.Guideline2_3.2_3_1',
3637
'Principle2.Guideline2_4.2_4_1',
3738
'Principle2.Guideline2_4.2_4_2',
3839
'Principle2.Guideline2_4.2_4_3',
3940
'Principle2.Guideline2_4.2_4_4',
41+
'Principle2.Guideline2_5.2_5_1',
42+
'Principle2.Guideline2_5.2_5_2',
43+
'Principle2.Guideline2_5.2_5_3',
44+
'Principle2.Guideline2_5.2_5_4',
4045
'Principle3.Guideline3_1.3_1_1',
4146
'Principle3.Guideline3_2.3_2_1',
4247
'Principle3.Guideline3_2.3_2_2',

Standards/WCAG2AA/ruleset.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
_global.HTMLCS_WCAG2AA = {
1515
name: 'WCAG2AA',
16-
description: 'Web Content Accessibility Guidelines (WCAG) 2.0 AA',
16+
description: 'Web Content Accessibility Guidelines (WCAG) 2.1 AA',
1717
sniffs: [
1818
{
1919
standard: 'WCAG2AAA',
@@ -27,15 +27,22 @@ _global.HTMLCS_WCAG2AA = {
2727
'Principle1.Guideline1_3.1_3_1_A',
2828
'Principle1.Guideline1_3.1_3_2',
2929
'Principle1.Guideline1_3.1_3_3',
30+
'Principle1.Guideline1_3.1_3_4',
31+
'Principle1.Guideline1_3.1_3_5',
3032
'Principle1.Guideline1_4.1_4_1',
3133
'Principle1.Guideline1_4.1_4_2',
3234
'Principle1.Guideline1_4.1_4_3',
3335
'Principle1.Guideline1_4.1_4_3_F24',
3436
'Principle1.Guideline1_4.1_4_3_Contrast',
3537
'Principle1.Guideline1_4.1_4_4',
3638
'Principle1.Guideline1_4.1_4_5',
39+
'Principle1.Guideline1_4.1_4_10',
40+
'Principle1.Guideline1_4.1_4_11',
41+
'Principle1.Guideline1_4.1_4_12',
42+
'Principle1.Guideline1_4.1_4_13',
3743
'Principle2.Guideline2_1.2_1_1',
3844
'Principle2.Guideline2_1.2_1_2',
45+
'Principle2.Guideline2_1.2_1_4',
3946
'Principle2.Guideline2_2.2_2_1',
4047
'Principle2.Guideline2_2.2_2_2',
4148
'Principle2.Guideline2_3.2_3_1',
@@ -46,6 +53,10 @@ _global.HTMLCS_WCAG2AA = {
4653
'Principle2.Guideline2_4.2_4_5',
4754
'Principle2.Guideline2_4.2_4_6',
4855
'Principle2.Guideline2_4.2_4_7',
56+
'Principle2.Guideline2_5.2_5_1',
57+
'Principle2.Guideline2_5.2_5_2',
58+
'Principle2.Guideline2_5.2_5_3',
59+
'Principle2.Guideline2_5.2_5_4',
4960
'Principle3.Guideline3_1.3_1_1',
5061
'Principle3.Guideline3_1.3_1_2',
5162
'Principle3.Guideline3_2.3_2_1',
@@ -57,7 +68,8 @@ _global.HTMLCS_WCAG2AA = {
5768
'Principle3.Guideline3_3.3_3_3',
5869
'Principle3.Guideline3_3.3_3_4',
5970
'Principle4.Guideline4_1.4_1_1',
60-
'Principle4.Guideline4_1.4_1_2'
71+
'Principle4.Guideline4_1.4_1_2',
72+
'Principle4.Guideline4_1.4_1_3'
6173
]
6274
}
6375
],

Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_1/1_1_1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
5656
* Driver function for the null alt text tests.
5757
*
5858
* This takes the generic result given by the alt text testing functions,
59-
* and converts them into WCAG 2.0-specific messages.
59+
* and converts them into WCAG 2.1-specific messages.
6060
*
6161
* @param {DOMNode} element The element to test.
6262
*/
@@ -337,7 +337,7 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
337337
* Driver function for the media alternative (object/applet) tests.
338338
*
339339
* This takes the generic result given by the media alternative testing function,
340-
* and converts them into WCAG 2.0-specific messages.
340+
* and converts them into WCAG 2.1-specific messages.
341341
*
342342
* @param {DOMNode} element The element to test.
343343
*/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* +--------------------------------------------------------------------+
3+
* | This HTML_CodeSniffer file is Copyright (c) |
4+
* | Squiz Pty Ltd (ABN 77 084 670 600) |
5+
* +--------------------------------------------------------------------+
6+
* | IMPORTANT: Your use of this Software is subject to the terms of |
7+
* | the Licence provided in the file licence.txt. If you cannot find |
8+
* | this file please contact Squiz (www.squiz.com.au) so we may |
9+
* | provide you a copy. |
10+
* +--------------------------------------------------------------------+
11+
*
12+
*/
13+
14+
_global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_4 = {
15+
/**
16+
* Determines the elements to register for processing.
17+
*
18+
* Each element of the returned array can either be an element name, or "_top"
19+
* which is the top element of the tested code.
20+
*
21+
* @returns {Array} The list of elements.
22+
*/
23+
register: function()
24+
{
25+
return ['_top'];
26+
27+
},
28+
29+
/**
30+
* Process the registered element.
31+
*
32+
* @param {DOMNode} element The element registered.
33+
* @param {DOMNode} top The top element of the tested code.
34+
*/
35+
process: function(element, top)
36+
{
37+
HTMLCS.addMessage(HTMLCS.NOTICE, top,
38+
_global.HTMLCS.getTranslation("1_3_4.RestrictView"), '');
39+
}
40+
};

0 commit comments

Comments
 (0)