Skip to content

fix(aria-required-children): do not fail for children with aria-hidden#3949

Merged
straker merged 2 commits intodevelopfrom
required-children-hidden
Mar 22, 2023
Merged

fix(aria-required-children): do not fail for children with aria-hidden#3949
straker merged 2 commits intodevelopfrom
required-children-hidden

Conversation

@straker
Copy link
Copy Markdown
Contributor

@straker straker commented Mar 20, 2023

Closes: #3850

@straker straker requested a review from a team as a code owner March 20, 2023 22:34
export { default as isOpaque } from './is-opaque';
export { default as isSkipLink } from './is-skip-link';
export { default as isVisibleToScreenReaders } from './is-visible-for-screenreader';
export { default as isVisibleToScreenReaders } from './is-visible-to-screenreader';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the file names were still using for instead of to so changed those to match the name of the function while I was there.

This comment was marked as spam.

const ownedElements = getOwnedVirtual(virtualNode);
for (let i = 0; i < ownedElements.length; i++) {
const ownedElement = ownedElements[i];
if (ownedElement.props.nodeType !== 1) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to ignore non-element nodes as isVisibletoScreenreaders calls into isHiddenForEveryone which tries to get the computed style for display, which fails for non-element nodes

Copy link
Copy Markdown
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. If you haven't already, can you look if this same problem may need to be fixed on the list and definition-list rules? Separate issue if so.

@straker
Copy link
Copy Markdown
Contributor Author

straker commented Mar 22, 2023

<ul>
  <div aria-hidden="true">foo</div>
  <li>bar</li>
</ul>

passes the list rule, and

<dl>
  <span aria-hidden="true">foo</span>
  <dt>bar</dt>
  <dd>baz</dd>
</dl>

passes the definition-list rule.

@lipalath-ms
Copy link
Copy Markdown

Has this fix been released? I upgraded axe-core to 4.7.2 and I still the issue. Please let me know.

@straker
Copy link
Copy Markdown
Contributor Author

straker commented May 25, 2023

@ilantom This should have been fixed in 4.7.1 I believe. Could you provide a code sample of it failing? It was validated for the original issue #3850 (comment).

@lipalath-ms
Copy link
Copy Markdown

@straker
Copy link
Copy Markdown
Contributor Author

straker commented May 25, 2023

@ilantom I exported the code to codepen and don't see any aria-required-children violations

screenshot of violations for the page showing empty-table-header, image-alt, landmark-one-main, page-has-heading-one, and region

@lipalath-ms
Copy link
Copy Markdown

You are right - I'm unable to repro the issue after exporting the code to codepen but I see the issue here:

image

same for my site

@straker
Copy link
Copy Markdown
Contributor Author

straker commented May 25, 2023

Is your site public that I could take a look at it? Running axe-core on the microsoft page itself still does not show a violation for aria-required-children. However the microsoft page has a bunch of CORS and CSP issues when trying to run axe-core so I'm not exactly confident in the final results.

rafaelpaniago1 added a commit to masganem/axe-core-mes-20252 that referenced this pull request Nov 7, 2025
Implementação da correção do falso positivo em aria-required-children
quando elementos filhos têm aria-hidden="true".

Problema:
- Elementos com aria-hidden="true" estavam causando falhas
- Estes elementos não fazem parte da árvore de acessibilidade
- O check verificava atributos ARIA globais mas não visibilidade

Solução aplicada:
1. Importar isVisibleToScreenReaders() de commons/dom
2. Adicionar check para nodeType !== 1 (ignorar nós de texto)

Arquivo modificado: lib/checks/aria/aria-required-children-evaluate.js

Comparação com solução oficial (PR dequelabs#3949):
✅ LÓGICA IDÊNTICA - 95% similar
- Mesmas verificações e mesma ordem
- Adicionei comentários explicativos (melhor documentação)
- Solução oficial: 9 arquivos (renomeação + testes)
- Minha solução: 1 arquivo (core fix apenas)

A diferença principal está no escopo:
- Oficial renomeou is-visible-for-screenreaders → is-visible-to-screenreader
- Oficial atualizou todos os imports (9 arquivos)
- Oficial adicionou 217 linhas de testes

Análise completa em: ANALISE-ISSUE-3850.md

Referências:
- Issue: dequelabs#3850
- PR oficial: dequelabs#3949
- ACT Rule: https://www.w3.org/WAI/standards-guidelines/act/rules/ff89c9/proposed/
- Commit oficial: 8714d6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive in aria-required-children "unknown" path for child not in accessibility tree with aria-hidden="true"

4 participants