Skip to content

Commit

Permalink
fix html as scroll region
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed Jan 8, 2020
1 parent fe903ae commit 4ed00b2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/commons/dom/get-element-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,14 @@ function createGrid(

vNode._stackingOrder = [0];
addNodeToGrid(rootGrid, vNode);

if (axe.utils.getScroll(vNode.actualNode)) {
const subGrid = {
container: vNode,
cells: []
};
vNode._subGrid = subGrid;
}
}

// IE11 requires the first 3 parameters
Expand Down
25 changes: 25 additions & 0 deletions test/commons/dom/get-element-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@ describe('dom.getElementStack', function() {
});

describe('scroll regions', function() {
var origHeight = document.documentElement.style.height;
var origOverflow = document.documentElement.style.overflowY;

afterEach(function() {
document.documentElement.style.height = origHeight;
document.documentElement.style.overflowY = origOverflow;
});

it('should return stack of scroll regions', function() {
fixture.innerHTML =
'<main id="1">' +
Expand Down Expand Up @@ -433,6 +441,23 @@ describe('dom.getElementStack', function() {
var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '5', '4', '3', '2', '1', 'fixture']);
});

it('should handle html as a scroll region', function() {
fixture.innerHTML =
'<main id="1">' +
'<div id="2" style="overflow:auto">' +
'<div id="3" style="height:100px">' +
'<p id="target">Hello World</p>' +
'</div>' +
'</div>' +
'</main>';
document.documentElement.style.height = '5000px';
document.documentElement.style.overflowY = 'scroll';
axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '3', '2', '1', 'fixture']);
});
});

describe('dom.getClientElementStack', function() {
Expand Down

0 comments on commit 4ed00b2

Please sign in to comment.