Skip to content

Commit

Permalink
fix(color-contrast): fix color-contrast check when running in an exte…
Browse files Browse the repository at this point in the history
…nsion (#3838)
  • Loading branch information
thuey authored Dec 22, 2022
1 parent d5f6ca9 commit 31a3e01
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/commons/color/get-background-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,24 @@ function fullyEncompasses(node, rects) {
rects = Array.isArray(rects) ? rects : [rects];

const nodeRect = node.getBoundingClientRect();
let { right, bottom } = nodeRect;
const style = window.getComputedStyle(node);
const overflow = style.getPropertyValue('overflow');

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

return rects.every(rect => {
return (
rect.top >= nodeRect.top &&
rect.bottom <= nodeRect.bottom &&
rect.bottom <= bottom &&
rect.left >= nodeRect.left &&
rect.right <= nodeRect.right
rect.right <= right
);
});
}
Expand Down

0 comments on commit 31a3e01

Please sign in to comment.