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(required-children): consider overriding descendant role(s) when validating required child role(s) #2131

Merged
merged 6 commits into from
Apr 7, 2020

Conversation

jeeyyy
Copy link
Contributor

@jeeyyy jeeyyy commented Mar 25, 2020

Closes issue:

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Code is reviewed for security

@jeeyyy jeeyyy requested a review from a team as a code owner March 25, 2020 14:35
@straker
Copy link
Contributor

straker commented Mar 27, 2020

Do we need to fail on this test case?

<div role="list" aria-owns="list"></div>

<div id="list">
  <div role="tabpanel">
    <div role="listitem"></div>
  </div>
</div>

@jeeyyy jeeyyy requested a review from straker April 1, 2020 10:10
Copy link
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

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

Both of the suggestions are optional, you can make the changes if you so feel.

} else {
return false;
const items = isOwns
? Array.from(el.children).reduce(
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly is this reduce doing? It looks like it's just pushing the children onto an array with the parent element. If that's the case it would be cleaner to just use concat.

const items = (isOwns ? [el] : []).concat(Array.from(el.children));

: !!axe.utils.querySelectorAll(virtualTree, selector)[0];
const ownedElements = idrefs(node, 'aria-owns');
const descendantRole = getDescendantRole(node, ownedElements);
const missing = missingRequiredChildren(
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of upping the eslint max-params limit you could pass all these as a single object and destructure it.

missingRequiredChildren({
  node,
  childRoles,
  all,
  role,
  ownedElements,
  descendantRole
});

function missingRequiredChildren({ 
  node,
  childRoles,
  all,
  role,
  ownedElements,
  descendantRole
}) {
  // ...
}

@jeeyyy jeeyyy merged commit e1c11dd into develop Apr 7, 2020
@jeeyyy jeeyyy deleted the fix-aria-required-children branch April 7, 2020 14:24
paulirish pushed a commit to paulirish/axe-core that referenced this pull request Jun 5, 2020
@JustSlone
Copy link

JustSlone commented Sep 18, 2020

@jeeyyy hey, question on this change. I'm not 100% sure, but this change seems to result in axe-core to flagging issues where role="group" is used to group menuitems. Was this intentional?

Example that seems like it should be OK, but fails (Example pulled from: The MDN Example #2 on using group role)

<div role="menu">
  <ul role="group">
    <li role="menuitem">Inbox</li>
    <li role="menuitem">Archive</li>
    <li role="menuitem">Trash</li>
  </ul>
  <ul role="group">
    <li role="menuitem">Custom Folder 1</li>
    <li role="menuitem">Custom Folder 2</li>
    <li role="menuitem">Custom Folder 3</li>
  </ul>
  <ul role="group">
    <li role="menuitem">New Folder</li>
  </ul>
</div>

Repro gist for convenience

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.

3 participants