Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(page-no-duplicate-main): do not fail for duplicate hidden elements #2000

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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
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
Original file line number Diff line number Diff line change
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