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

False positives for containers with role="presentation" #274

Closed
TrevorBurnham opened this issue Dec 9, 2019 · 3 comments
Closed

False positives for containers with role="presentation" #274

TrevorBurnham opened this issue Dec 9, 2019 · 3 comments
Assignees
Labels

Comments

@TrevorBurnham
Copy link

Prompted by mui/material-ui#18106

If you set role="presentation" on any container element whose descendants have a semantic meaning, you'll get the warning:

This element's role is "presentation" but contains child elements with semantic meaning.

For example, this markup triggers the warning:

<div role="presentation">
  <a href="http://example.com">Link</a>
</div>

The sniff that generates the warning seems to be based on an overly broad interpretation of F92:

This failure occurs when a role of presentation is applied to an element whose purpose is to convey information or relationships in the content.

The example given is that a <table> element with role="presentation" no longer functions as a table. The important thing is the element itself, not its descendants. The WAI-ARIA spec specifically states that when you set role="presentation" on an element,

The roles, states, and properties of each descendant element remain visible to assistive technologies


I recommend that the sniff should be rewritten to apply more narrowly. At the very least, it should ignore elements like div and span that already have no semantic meaning, since setting role="presentation" on those elements has no effect on assistive technologies.

This came up previously as #191 in the context of <svg> elements. /cc @ironikart

@ironikart
Copy link
Contributor

Thanks @TrevorBurnham. I'm marking this as a bug since I believe you are correct, the sniff is currently too broad and HTMLCS will show an error in cases where it isn't an actual failure. I'll look into improving this.

ironikart added a commit that referenced this issue Dec 13, 2019
@ironikart
Copy link
Contributor

I'm closing this issue off. The last update I made is as far as I'm able to reasonably take the checks and addresses the issue.

@oliviertassinari
Copy link

Awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants