Skip to content

Commit

Permalink
fix(page-no-duplicate-main): do not fail for duplicate hidden elements (
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed Jan 29, 2020
1 parent 6429e60 commit 414dfb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checks/keyboard/page-no-duplicate.js
Expand Up @@ -15,7 +15,7 @@ axe._cache.set(key, true);
let elms = axe.utils.querySelectorAllFilter(
axe._tree[0],
options.selector,
elm => elm !== virtualNode
elm => elm !== virtualNode && axe.commons.dom.isVisible(elm.actualNode)
);

// Filter elements that, within certain contexts, don't map their role.
Expand Down
9 changes: 9 additions & 0 deletions test/checks/keyboard/page-no-duplicate.js
Expand Up @@ -50,6 +50,15 @@ describe('page-no-duplicate', function() {
assert.isTrue(check.evaluate.apply(checkContext, params));
});

it('should return true if there is more than one element matching the selector but only one is visible', function() {
var options = { selector: 'main' };
var params = checkSetup(
'<div><main id="target"></main><main id="dup" style="display:none;"></main></div>',
options
);
assert.isTrue(check.evaluate.apply(checkContext, params));
});

(shadowSupported ? it : xit)(
'should return false if there is a second matching element inside the shadow dom',
function() {
Expand Down

0 comments on commit 414dfb1

Please sign in to comment.