Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(aria): $mdAria should not use texts from aria-hidden nodes #7957

Closed

Conversation

devversion
Copy link
Member

  • $mdAria is currently just using textContent for retrieving the aria-label.
    This is not valid, since some child-texts can be hidden in aria (`aria-hidden="true")
  • Using a TreeWalker is super elegant and performant.
    The current use of the TreeWalker is supported by all browser we support.

Fixes #7376

@devversion devversion added a11y This issue is related to accessibility needs: review This PR is waiting on review from the team labels Apr 8, 2016
@devversion
Copy link
Member Author

FYI: Waiting for @topherfangio's fix for the current CI issues :) Thx.

@ThomasBurleson
Copy link
Contributor

@devversion - please rebase.

var text = '';

var node;
while (node = walker.nextNode()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than walking through all of the nodes here, can you not just use the third parameter filter of the createTreeWalker() method? I would assume you could just pass the isAriaHiddenNoe() method to it (wrapped in an object I think) and it would filter the nodes for you.

I guess you would still have to traverse the remaining nodes to add the text content, but it might shorten the code for you a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

@topherfangio I intentionally didn't use the filter for the TreeWalker, because it's not supported by IE browsers and this will break ngMaterial on IE browsers.

Additionally, the filter is actually doing the same as my code, it's just a shorter / native code + The amount of nodes we iterate through is really minimized, because we're only iterating through the text nodes.

* $mdAria is currently just using `textContent` for retrieving the `aria-label`.
  This is not valid, since some child-texts can be hidden in aria (`aria-hidden="true")

* Using a TreeWalker is super elegant and performant.
  The current use of the TreeWalker is supported by all browser we support.

Fixes angular#7376
@devversion devversion force-pushed the fix/aria-textcontent-iteration branch from c3de5d6 to 7a95f2a Compare April 9, 2016 08:16
@devversion
Copy link
Member Author

@ThomasBurleson Done, thanks for the fix 👍

@devversion devversion deleted the fix/aria-textcontent-iteration branch April 19, 2016 19:47
ilovett pushed a commit to ilovett/material that referenced this pull request Apr 22, 2016
* $mdAria is currently just using `textContent` for retrieving the `aria-label`.
  This is not valid, since some child-texts can be hidden in aria (`aria-hidden="true")

* Using a TreeWalker is super elegant and performant.
  The current use of the TreeWalker is supported by all browser we support.

Fixes angular#7376

Closes angular#7957
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a11y This issue is related to accessibility needs: review This PR is waiting on review from the team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants