testaro 28.2.0 → 28.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "28.2.0",
3
+ "version": "28.2.2",
4
4
  "description": "Run 960 web accessibility tests from 9 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,6 +33,9 @@ exports.getLocatorData = async loc => {
33
33
  if (! text) {
34
34
  text = element.outerHTML.replace(/\s+/g, ' ').trim();
35
35
  }
36
+ if (/^<[^<>]+>$/.test(text)) {
37
+ text = element.parentElement.outerHTML.replace(/\s+/g, ' ').trim();
38
+ }
36
39
  // Location.
37
40
  let location = {
38
41
  doc: 'dom',
package/testaro/hover.js CHANGED
@@ -65,7 +65,6 @@ exports.reporter = async (page, withItems) => {
65
65
  }
66
66
  }
67
67
  catch(error) {
68
- console.log(`Hovering timed out (${error.message.replace(/[\n].+/s, '')})`);
69
68
  }
70
69
  }
71
70
  // Populate and return the result.
@@ -15,29 +15,28 @@ const {init, report} = require('../procs/testaro');
15
15
  // Runs the test and returns the result.
16
16
  exports.reporter = async (page, withItems) => {
17
17
  // Initialize the locators and result.
18
- const all = await init(page, 'body *', {has: page.locator('br + br')});
18
+ const all = await init(page, 'body br + br');
19
19
  // For each locator:
20
20
  for (const loc of all.allLocs) {
21
- const isBad = await loc.evaluate(el => {
22
- // Get whether it has 2 adjacent br elements with no non-space text between them.
23
- const childNodes = Array.from(el.childNodes);
24
- const realChildNodes = childNodes.filter(
25
- node => node.nodeType !== Node.TEXT_NODE || node.nodeValue.replace(/\s/g, '').length
26
- );
27
- return realChildNodes.some(
28
- (node, index) => node.nodeName === 'BR' && realChildNodes[index + 1].nodeName === 'BR'
29
- );
21
+ // Return whether the second br element violates the rule.
22
+ const parentTagNameIfBad = await loc.evaluate(el => {
23
+ el.parentElement.normalize();
24
+ const previousSib = el.previousSibling;
25
+ return previousSib.nodeType === Node.ELEMENT_NODE
26
+ || previousSib.nodeType === Node.TEXT_NODE && /^\s+$/.test(previousSib)
27
+ ? el.parentElement.tagName
28
+ : false;
30
29
  });
31
30
  // If it does:
32
- if (isBad) {
31
+ if (parentTagNameIfBad) {
33
32
  // Add the locator to the array of violators.
34
- all.locs.push(loc);
33
+ all.locs.push([loc, parentTagNameIfBad]);
35
34
  }
36
- }
35
+ };
37
36
  // Populate and return the result.
38
37
  const whats = [
39
- 'Element contains 2 or more adjacent br elements that may be a pseudo-paragraph',
38
+ 'Adjacent br elements within a __param__ element may be pseudo-paragraphs',
40
39
  'Elements contain 2 or more adjacent br elements that may be pseudo-paragraphs'
41
40
  ];
42
- return await report(withItems, all, 'pseudoP', whats, 0);
41
+ return await report(withItems, all, 'pseudoP', whats, 0, 'br');
43
42
  };
package/tests/testaro.js CHANGED
@@ -56,7 +56,7 @@ const evalRules = {
56
56
  miniText: 'text smaller than 11 pixels',
57
57
  motion: 'motion without user request',
58
58
  nonTable: 'table elements used for layout',
59
- opFoc: 'Operable elements that are not Tab-focusable',
59
+ opFoc: 'operable elements that are not Tab-focusable',
60
60
  pseudoP: 'adjacent br elements suspected of nonsemantically simulating p elements',
61
61
  radioSet: 'radio buttons not grouped into standard field sets',
62
62
  role: 'invalid and native-replacing explicit roles',