testaro 55.5.13 → 55.6.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "55.5.13",
3
+ "version": "55.6.0",
4
4
  "description": "Run 1000 web accessibility tests from 11 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2023–2024 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2023–2025 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  MIT License
5
5
 
@@ -30,6 +30,9 @@
30
30
  */
31
31
 
32
32
  exports.isInlineLink = async loc => await loc.evaluate(element => {
33
+ // Returns the normalized text content of an element.
34
+ const realTextOf = element => element ? element.textContent.replace(/\s/g, '') : '';
35
+ const blockElementTypes = 'p, div, li, h1, h2, h3, h4, h5, h6';
33
36
  // If the element is not a link:
34
37
  if (element.tagName !== 'A' && element.getAttribute('role') !== 'link') {
35
38
  // Classify it as not an inline link.
@@ -37,36 +40,16 @@ exports.isInlineLink = async loc => await loc.evaluate(element => {
37
40
  }
38
41
  // Otherwise, i.e. if it is a link:
39
42
  else {
40
- let listAncestor;
41
43
  // Initialize the link as inline.
42
44
  let result = true;
43
- // If its display style property is block:
44
- const styleDec = window.getComputedStyle(element);
45
- if (styleDec.display === 'block') {
45
+ // If its display style property is block or is tantamount to block:
46
+ if (
47
+ window.getComputedStyle(element).display === 'block'
48
+ || realTextOf(element.closest(blockElementTypes)) === realTextOf(element)
49
+ ) {
46
50
  // Reclassify the link as non-inline.
47
51
  result = false;
48
52
  }
49
- // Otherwise, if it is in a list item in a list of at least 2 links:
50
- else if (listAncestor = element.closest('ul, ol')) {
51
- if (listAncestor.children.length > 1 && Array.from(listAncestor.children).every(child => {
52
- const isValidListItem = child.tagName === 'LI';
53
- const has1Link = child.querySelectorAll('a').length === 1;
54
- return isValidListItem && has1Link;
55
- })) {
56
- // If the list text is entirely link text:
57
- const listText = listAncestor.textContent.replace(/\s/g, '');
58
- let linkTextRaw = '';
59
- listAncestor.querySelectorAll('a').forEach(link => {
60
- linkTextRaw += link.textContent;
61
- });
62
- const linkText = linkTextRaw.replace(/\s/g, '');
63
- console.log(linkText);
64
- if (listText === linkText && listText.length) {
65
- // Reclassify the link as non-inline.
66
- result = false;
67
- }
68
- }
69
- }
70
53
  // Return the result.
71
54
  return result;
72
55
  }