Skip to content

Commit

Permalink
fix(color-contrast): correctly handle nested scroll regions (#3212)
Browse files Browse the repository at this point in the history
* fix(color-contrast): correctly handle nested scroll regions

* revert changes from previous pr
  • Loading branch information
straker authored Oct 15, 2021
1 parent 4937bfa commit 22db29c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/commons/dom/get-rect-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ function findScrollRegionParent(vNode, parentVNode) {
const checkedNodes = [vNode];

while (parentVNode) {
if (parentVNode._scrollRegionParent) {
scrollRegionParent = parentVNode._scrollRegionParent;
if (getScroll(parentVNode.actualNode)) {
scrollRegionParent = parentVNode;
break;
}

if (getScroll(parentVNode.actualNode)) {
scrollRegionParent = parentVNode;
if (parentVNode._scrollRegionParent) {
scrollRegionParent = parentVNode._scrollRegionParent;
break;
}

Expand Down
15 changes: 15 additions & 0 deletions test/commons/dom/get-element-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,5 +572,20 @@ describe('dom.getElementStack', function() {
var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '3', '2', '1', 'fixture']);
});

it('should use correct scroll region parent', function() {
fixture.innerHTML =
'<div id="1" style="overflow: scroll; height: 50px;">' +
'<div id="2" style="overflow: scroll; height: 100px;">' +
'<div id="3">' +
'<div id="target" style="margin-top: 200px;">text</div>' +
'</div>' +
'</div>' +
'</div>';
axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '3', '2', '1', 'fixture']);
});
});
});

0 comments on commit 22db29c

Please sign in to comment.