Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit fb92be6

Browse files
committed
fix(accessibility): improve output for long elements
Instead of just printing the first N characters of the element's template, print the first and last N/2. See #1854
1 parent 2a765c7 commit fb92be6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

plugins/accessibility/index.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ function runChromeDevTools(config) {
175175
var elementPromises = [],
176176
elementStringLength = 200;
177177

178+
function trimText(text) {
179+
if (text.length > elementStringLength) {
180+
return text.substring(0, elementStringLength / 2) + ' ... '
181+
+ text.substring(text.length - elementStringLength / 2);
182+
} else {
183+
return text;
184+
}
185+
}
186+
178187
var testHeader = 'Chrome A11Y - ';
179188

180189
return browser.executeScript_(data, 'a11y developer tool rules').then(function(results) {
@@ -189,7 +198,7 @@ function runChromeDevTools(config) {
189198
elem.getOuterHtml().then(function(text) {
190199
return {
191200
code: result.rule.code,
192-
list: text.substring(0, elementStringLength)
201+
list: trimText(text)
193202
};
194203
})
195204
);

0 commit comments

Comments
 (0)