testaro 32.2.2 → 32.2.3

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": "32.2.2",
3
+ "version": "32.2.3",
4
4
  "description": "Run 960 web accessibility tests from 9 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,8 +23,7 @@
23
23
  /*
24
24
  headingAmb
25
25
  Related to ASLint rule headings-sibling-unique.
26
- This test reports same-level heading siblings in the heading hierarchy that have identical text
27
- contents.
26
+ This test reports adjacent headings with the same levels and text contents.
28
27
  */
29
28
 
30
29
  // ########## IMPORTS
@@ -49,21 +48,24 @@ exports.reporter = async (page, withItems) => {
49
48
  const badIndexes = [];
50
49
  // For each heading:
51
50
  headings.forEach((heading, index) => {
52
- // If any same-level and same-text heading precedes it:
53
- const priors = headings.slice(0, index);
54
- priors.forEach((prior, priorIndex) => {
51
+ // Get its level.
52
+ const level = heading.level;
53
+ // If there are prior non-inferior headings and the last one has the same-level and text:
54
+ // Get the prior headings.
55
+ const priorHeadings = headings.slice(0, index);
56
+ // Get the non-inferior ones among them.
57
+ const nonInferiors = priorHeadings.filter(priorHeading => priorHeading.level <= level);
58
+ // If there are any:
59
+ const nonInferiorCount = nonInferiors.length;
60
+ if (nonInferiorCount) {
61
+ // Get the last of them.
62
+ const prior = nonInferiors[nonInferiorCount - 1];
63
+ // If they have the same level and text:
55
64
  if (['tagName', 'textContent'].every(property => prior[property] === heading[property])) {
56
- // If no superior heading exists between them:
57
- if (
58
- headings
59
- .slice(priorIndex + 1, index)
60
- .every(betweenHeading => betweenHeading.tagName[1] >= heading.tagName[1])
61
- ) {
62
- // Add the index of the later heading to the index of violating headings.
63
- badIndexes.push(headings.indexOf(heading));
64
- }
65
+ // Add the index of the later heading to the index of violating headings.
66
+ badIndexes.push(index);
65
67
  }
66
- });
68
+ }
67
69
  });
68
70
  return badIndexes;
69
71
  });