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

Ancestry selector of shadow root child not guaranteed unique #4563

Open
WilcoFiers opened this issue Aug 20, 2024 · 0 comments
Open

Ancestry selector of shadow root child not guaranteed unique #4563

WilcoFiers opened this issue Aug 20, 2024 · 0 comments
Labels
core Issues in the core code (lib/core) fix Bug fixes
Milestone

Comments

@WilcoFiers
Copy link
Contributor

WilcoFiers commented Aug 20, 2024

Working on some shadow DOM stuff, I noticed that in order to determine whether there are multiple children in the shadow root, we're checking parentElement. For children of the shadow root this is null, which results in an ancestry that just uses the node name. You can reproduce it in the following:

<script src="/axe.js"></script>
<script>
  window.onload = () => {
    axe.run({ runOnly: 'button-name', ancestry: true }, (err, results) => {
      console.log(err || results);
    });
  };
</script>
<custom-elm>
  <template shadowrootmode="open">
    <button></button>
    <button></button>
  </template>
</custom-elm>

This will give ['html > body > custom-elm', 'button'] as the ancestry for. BOTH buttons. This doesn't seem to happen with the regular selector axe-core has, which is probably why this has gone unnoticed for so long.

@WilcoFiers WilcoFiers added fix Bug fixes core Issues in the core code (lib/core) labels Aug 20, 2024
@WilcoFiers WilcoFiers added this to the Axe-core 4.11 milestone Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues in the core code (lib/core) fix Bug fixes
Projects
None yet
Development

No branches or pull requests

1 participant