-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(valid-lang): ignore lang on elements with no text (#3523)
* fix(valid-lang): ignore lang on elements with no text * Delete broken / unnecessary test * Fix failing tests * fix broken test * Address feedback * Disable flakey IE test * Make hasLangText part of valid-lang check
- Loading branch information
1 parent
736bad9
commit fd85f39
Showing
15 changed files
with
367 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { hasChildTextNodes } from './has-content-virtual'; | ||
import isVisualContent from './is-visual-content'; | ||
import isVisible from './is-visible'; | ||
|
||
/** | ||
* Check that a node has text, or an accessible name which language is defined by the | ||
* nearest ancestor's lang attribute. | ||
* @param {VirtualNode} virtualNode | ||
* @return boolean | ||
*/ | ||
export default function hasLangText(virtualNode) { | ||
if (typeof virtualNode.children === 'undefined' || hasChildTextNodes(virtualNode)) { | ||
return true; | ||
} | ||
if (virtualNode.props.nodeType === 1 && isVisualContent(virtualNode)) { | ||
// See: https://github.com/dequelabs/axe-core/issues/3281 | ||
return !!axe.commons.text.accessibleTextVirtual(virtualNode); | ||
} | ||
return virtualNode.children.some(child => ( | ||
!child.attr('lang') && // non-empty lang | ||
hasLangText(child) && // has text | ||
isVisible(child, true) // Not hidden for AT | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.