testaro 18.12.0 → 18.13.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 +1 -1
- package/testaro/zIndex.js +21 -57
package/package.json
CHANGED
package/testaro/zIndex.js
CHANGED
|
@@ -10,68 +10,32 @@
|
|
|
10
10
|
|
|
11
11
|
// ########## IMPORTS
|
|
12
12
|
|
|
13
|
-
// Module to
|
|
14
|
-
const {
|
|
13
|
+
// Module to perform common operations.
|
|
14
|
+
const {init, report} = require('../procs/testaro');
|
|
15
15
|
|
|
16
16
|
// ########## FUNCTIONS
|
|
17
17
|
|
|
18
|
+
// Runs the test and returns the result.
|
|
18
19
|
exports.reporter = async (page, withItems) => {
|
|
19
|
-
// Initialize the result.
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// Get its Z index.
|
|
29
|
-
const zIndex = await loc.evaluate(element => {
|
|
30
|
-
const styleDec = window.getComputedStyle(element);
|
|
31
|
-
return styleDec.zIndex;
|
|
20
|
+
// Initialize the locators and result.
|
|
21
|
+
const all = await init(page, 'body *');
|
|
22
|
+
// For each locator:
|
|
23
|
+
for (const loc of all.allLocs) {
|
|
24
|
+
// Get whether its element violates the rule.
|
|
25
|
+
const badZ = await loc.evaluate(el => {
|
|
26
|
+
const styleDec = window.getComputedStyle(el);
|
|
27
|
+
const {zIndex} = styleDec;
|
|
28
|
+
return zIndex !== 'auto' ? zIndex : null;
|
|
32
29
|
});
|
|
33
|
-
// If it
|
|
34
|
-
if (
|
|
35
|
-
// Add to the
|
|
36
|
-
|
|
37
|
-
// If itemization is required:
|
|
38
|
-
if (withItems) {
|
|
39
|
-
// Get data on the element.
|
|
40
|
-
const elData = await getLocatorData(loc);
|
|
41
|
-
// Add an instance to the result.
|
|
42
|
-
standardInstances.push({
|
|
43
|
-
ruleID: 'zIndex',
|
|
44
|
-
what: `Element has a non-default Z index (${zIndex})`,
|
|
45
|
-
ordinalSeverity: 0,
|
|
46
|
-
tagName: elData.tagName,
|
|
47
|
-
id: elData.id,
|
|
48
|
-
location: elData.location,
|
|
49
|
-
excerpt: elData.excerpt
|
|
50
|
-
});
|
|
51
|
-
}
|
|
30
|
+
// If it does:
|
|
31
|
+
if (badZ) {
|
|
32
|
+
// Add the locator to the array of violators.
|
|
33
|
+
all.locs.push([loc, badZ]);
|
|
52
34
|
}
|
|
53
35
|
}
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
what: 'Elements have non-default Z indexes',
|
|
60
|
-
count: totals[0],
|
|
61
|
-
ordinalSeverity: 0,
|
|
62
|
-
tagName: '',
|
|
63
|
-
id: '',
|
|
64
|
-
location: {
|
|
65
|
-
doc: '',
|
|
66
|
-
type: '',
|
|
67
|
-
spec: ''
|
|
68
|
-
},
|
|
69
|
-
excerpt: ''
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
data,
|
|
74
|
-
totals,
|
|
75
|
-
standardInstances
|
|
76
|
-
};
|
|
36
|
+
// Populate and return the result.
|
|
37
|
+
const whats = [
|
|
38
|
+
'Element has a non-default Z index (__param__)', 'Elements have non-default Z indexes'
|
|
39
|
+
];
|
|
40
|
+
return await report(withItems, all, 'zIndex', whats, 0);
|
|
77
41
|
};
|