testaro 72.4.3 → 72.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/testaro/linkUl.js +20 -16
package/package.json
CHANGED
package/testaro/linkUl.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
/*
|
|
11
11
|
linkUl
|
|
12
|
-
This test reports failures to underline
|
|
12
|
+
This test reports failures to underline links that have adjacent text. Underlining and color are the traditional style properties that identify links. A link whose text is the entire text of its block may be recognizable without underlining, but otherwise links are difficult or impossible to distinguish visually from surrounding text if not underlined. Underlining links only on hover provides an indicator valuable only to mouse users, and even they must traverse the text with a mouse merely to discover which passages are links.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
// IMPORTS
|
|
@@ -21,24 +21,28 @@ const {doTest} = require('../procs/testaro');
|
|
|
21
21
|
// Runs the test and returns the result.
|
|
22
22
|
exports.reporter = async (page, catalog, withItems) => {
|
|
23
23
|
const getBadWhat = element => {
|
|
24
|
-
|
|
25
|
-
// If the element is not
|
|
26
|
-
if (!
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
let {display, textDecorationLine} = window.getComputedStyle(element);
|
|
25
|
+
// If the element is not underlined:
|
|
26
|
+
if (! textDecorationLine.includes('underline')) {
|
|
27
|
+
let ancestor = element;
|
|
28
|
+
// Get its closest non-inline ancestor.
|
|
29
|
+
while (display === 'inline') {
|
|
30
|
+
ancestor = ancestor.parentElement;
|
|
31
|
+
display = ancestor ? window.getComputedStyle(ancestor).display : null;
|
|
32
|
+
}
|
|
33
|
+
// Removes superfluous whitespace from a string.
|
|
34
|
+
const compact = string => string?.replace(/\s+/g, ' ')?.trim();
|
|
35
|
+
// If the rendered compacted text of that ancestor includes more than that of the element:
|
|
36
|
+
if (
|
|
37
|
+
compact(element.textContent) !== compact(ancestor?.textContent)
|
|
38
|
+
&& compact(element.innerText) !== compact(ancestor?.innerText)
|
|
39
|
+
) {
|
|
40
|
+
// Return a violation description.
|
|
41
|
+
return 'Element has adjacent text but is not underlined';
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
};
|
|
41
|
-
const whats = 'Links
|
|
45
|
+
const whats = 'Links with adjacent text are not underlined';
|
|
42
46
|
return await doTest(
|
|
43
47
|
page, catalog, withItems, 'linkUl', 'body a', whats, 1, getBadWhat.toString()
|
|
44
48
|
);
|