testaro 8.4.0 → 8.4.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tests/attVal.js +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "8.4.0",
3
+ "version": "8.4.2",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tests/attVal.js CHANGED
@@ -7,6 +7,7 @@ exports.reporter = async (page, attributeName, areLicit, values, withItems) => {
7
7
  const badAttributeData = await page.evaluate(
8
8
  args => {
9
9
  const attributeName = args[0];
10
+ // Whether the values are the licit or the illicit ones.
10
11
  const areLicit = args[1];
11
12
  const values = args[2];
12
13
  // Returns the text of an element.
@@ -15,15 +16,17 @@ exports.reporter = async (page, attributeName, areLicit, values, withItems) => {
15
16
  text = text.trim() || element.innerHTML;
16
17
  return text.replace(/\s+/sg, ' ').replace(/<>&/g, '').slice(0, limit);
17
18
  };
18
- const attributeElements = Array.from(document.body.querySelectorAll(`[${attributeName}]`));
19
+ // Get the elements (including the html element) with the attribute.
20
+ const attributeElements = Array.from(document.querySelectorAll(`[${attributeName}]`));
21
+ // Get those in which the attribute has an illicit value.
19
22
  const badElements = attributeElements
20
23
  .filter(el => {
21
24
  const value = el.getAttribute(attributeName);
22
25
  if (areLicit) {
23
- return values.includes(value);
26
+ return ! values.includes(value);
24
27
  }
25
28
  else {
26
- return ! values.includes(value);
29
+ return values.includes(value);
27
30
  }
28
31
  });
29
32
  const report = badElements.map(el => ({