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

fix(accessibility): improve output for long elements #1900

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion plugins/accessibility/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ function runChromeDevTools(config) {
var elementPromises = [],
elementStringLength = 200;

function trimText(text) {
if (text.length > elementStringLength) {
return text.substring(0, elementStringLength / 2) + ' ... '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have a total length of elementStringLength + 5. Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah (there's also some tabs at the beginning, so it's not the whole output string length anyway...).

+ text.substring(text.length - elementStringLength / 2);
} else {
return text;
}
}

var testHeader = 'Chrome A11Y - ';

return browser.executeScript_(data, 'a11y developer tool rules').then(function(results) {
Expand All @@ -189,7 +198,7 @@ function runChromeDevTools(config) {
elem.getOuterHtml().then(function(text) {
return {
code: result.rule.code,
list: text.substring(0, elementStringLength)
list: trimText(text)
};
})
);
Expand Down