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

Commit

Permalink
fix(accessibility): improve output for long elements
Browse files Browse the repository at this point in the history
Instead of just printing the first N characters of the element's template,
print the first and last N/2.

See #1854
  • Loading branch information
juliemr committed Mar 9, 2015
1 parent 2a765c7 commit fb92be6
Showing 1 changed file with 10 additions and 1 deletion.
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) + ' ... '
+ 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

0 comments on commit fb92be6

Please sign in to comment.