Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions lib/commons/color/get-background-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ function fullyEncompasses(node, rects) {
let { right, bottom } = nodeRect;
const style = window.getComputedStyle(node);
const overflow = style.getPropertyValue('overflow');
const paddingLeft = parseInt(style.getPropertyValue('padding-left'), 10);
const paddingRight = parseInt(style.getPropertyValue('padding-right'), 10);
const paddingTop = parseInt(style.getPropertyValue('padding-top'), 10);
const paddingBottom = parseInt(style.getPropertyValue('padding-bottom'), 10);

if (
['scroll', 'auto'].includes(overflow) ||
node instanceof window.HTMLHtmlElement
) {
right = nodeRect.left + node.scrollWidth;
bottom = nodeRect.top + node.scrollHeight;
right = nodeRect.left + node.scrollWidth + paddingLeft + paddingRight;
bottom = nodeRect.top + node.scrollHeight + paddingTop + paddingBottom;
}

return rects.every(rect => {
Expand Down
12 changes: 12 additions & 0 deletions test/commons/color/get-background-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,18 @@ describe('color.getBackgroundColor', function () {
assertColorsClose(actual, expected);
});

it('calculates background of a textarea', () => {
fixture.innerHTML =
'<textarea id="target" style="background: red">Hello</textarea>';
var target = fixture.querySelector('#target');
axe.testUtils.flatTreeSetup(fixture);
var bgNodes = [];
var actual = axe.commons.color.getBackgroundColor(target, bgNodes, 1);

var expected = new axe.commons.color.Color(255, 0, 0, 1);
assertColorsClose(actual, expected);
});

describe('body and document', function () {
it('returns the body background', function () {
fixture.innerHTML = '<div id="target">elm</div>';
Expand Down
4 changes: 4 additions & 0 deletions test/integration/rules/color-contrast/color-contrast.html
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,7 @@
>
Ignore.
</div>

<textarea id="pass24" style="background-color: white; color: black">
Hello world</textarea
>
3 changes: 2 additions & 1 deletion test/integration/rules/color-contrast/color-contrast.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
["#pass20"],
["#pass21"],
["#pass22"],
["#pass23"]
["#pass23"],
["#pass24"]
],
"incomplete": [
["#canttell1"],
Expand Down