testaro 64.8.2 → 64.8.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 +1 -1
- package/tests/wave.js +19 -15
package/package.json
CHANGED
package/tests/wave.js
CHANGED
|
@@ -114,21 +114,25 @@ exports.reporter = async (page, report, actIndex) => {
|
|
|
114
114
|
rule.wcag = guidelines || [];
|
|
115
115
|
// For each violation:
|
|
116
116
|
for (const index in rule.selectors) {
|
|
117
|
-
const selector = rule.selectors[index];
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
117
|
+
const selector = rule.selectors[index] || '';
|
|
118
|
+
let excerpt = '';
|
|
119
|
+
// If a selector is provided:
|
|
120
|
+
if (selector) {
|
|
121
|
+
// Get an excerpt of the element.
|
|
122
|
+
excerpt = await page.evaluate(selector => {
|
|
123
|
+
const element = document.querySelector(selector);
|
|
124
|
+
// If the selector matches an element:
|
|
125
|
+
if (element) {
|
|
126
|
+
// Get an excerpt of the element.
|
|
127
|
+
const rawExcerpt = element.textContent.trim() || element.outerHTML.trim();
|
|
128
|
+
const normalizedExcerpt = rawExcerpt.replace(/\s+/g, ' ');
|
|
129
|
+
return normalizedExcerpt.slice(0, 300);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return '';
|
|
133
|
+
}
|
|
134
|
+
}, selector);
|
|
135
|
+
}
|
|
132
136
|
// Convert the violation selector to a selector-excerpt pair.
|
|
133
137
|
rule.selectors[index] = [selector, excerpt];
|
|
134
138
|
}
|