Skip to content

Commit

Permalink
Merge pull request #2092 from dequelabs/noDuplicate
Browse files Browse the repository at this point in the history
fix(page-no-duplicate-contentinfo): do not fail when first element is inside landmark
  • Loading branch information
straker authored Mar 12, 2020
2 parents d3bd416 + e537fc7 commit eca7e05
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/checks/keyboard/page-no-duplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ axe._cache.set(key, true);
let elms = axe.utils.querySelectorAllFilter(
axe._tree[0],
options.selector,
elm => elm !== virtualNode && axe.commons.dom.isVisible(elm.actualNode)
elm => axe.commons.dom.isVisible(elm.actualNode)
);

// Filter elements that, within certain contexts, don't map their role.
Expand All @@ -29,6 +29,8 @@ if (typeof options.nativeScopeFilter === 'string') {
});
}

this.relatedNodes(elms.map(elm => elm.actualNode));
this.relatedNodes(
elms.filter(elm => elm !== virtualNode).map(elm => elm.actualNode)
);

return elms.length === 0;
return elms.length <= 1;
15 changes: 15 additions & 0 deletions test/checks/keyboard/page-no-duplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ describe('page-no-duplicate', function() {
assert.isFalse(check.evaluate.apply(checkContext, params));
});

it('should pass when there are two elements and the first is contained within a nativeSccopeFilter', function() {
var options = {
selector: 'footer, [role="contentinfo"]',
nativeScopeFilter: 'article'
};
var params = checkSetup(
'<article>' +
'<footer id="target">Article footer</footer>' +
'</article>' +
'<footer>Body footer</footer>',
options
);
assert.isTrue(check.evaluate.apply(checkContext, params));
});

(shadowSupported ? it : xit)(
'elements if its ancestor is outside the shadow DOM tree',
function() {
Expand Down

0 comments on commit eca7e05

Please sign in to comment.