testaro 28.2.0 → 28.2.1
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/procs/getLocatorData.js +3 -0
- package/testaro/pseudoP.js +14 -15
- package/tests/testaro.js +1 -1
package/package.json
CHANGED
package/procs/getLocatorData.js
CHANGED
|
@@ -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/pseudoP.js
CHANGED
|
@@ -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
|
|
18
|
+
const all = await init(page, 'body br + br');
|
|
19
19
|
// For each locator:
|
|
20
20
|
for (const loc of all.allLocs) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
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 (
|
|
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
|
-
'
|
|
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: '
|
|
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',
|