testing-library / testing-library/dom-testing-library
header/footer elements incorrectly inferred with banner/contentinfo role when nested in section
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 474
- PR merge metrics
- No merged PRs in 30d
Description
@testing-library/domversion: 10.4.0- Testing Framework and version: Jest
- DOM Environment:
Relevant code or config:
<header>Header</header>
<main>Main</main>
<section>
<header>Section header</header>
<footer>Section header</footer>
</section>
<footer>Footer</footer>
What you did:
Expected that only header/footer elements that are decedents of section elements don't have roles of banner / contentinfo as per the MDN docs:
element has an identical meaning to the banner landmark, unless it is a descendant of , , , , or , at which point exposes a generic role, and not the equivalent of the site-wide banner.
When it is an immediate descendant of the using the
element will automatically communicate a section has a role of contentinfo (save for a known issue in VoiceOver). If at all possible, prefer using instead. Note that a footer element nested within an article, aside, main, nav, or section is not considered contentinfo.
What happened:
Elements have the aforementioned roles.
Reproduction:
Problem description:
Conflicts with the MDN docs/browser accessibility tree.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and trace how DOM Testing Library infers roles for the header and footer elements. Compare the result with the documented expectations, then add regression coverage showing that elements nested in a section do not expose banner or contentinfo roles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- accessibility, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100