help-same-as-label-evaluate.js 675 B

12345678910111213141516171819202122232425262728
  1. import { labelVirtual, accessibleText, sanitize } from '../../commons/text';
  2. import { idrefs } from '../../commons/dom';
  3. function helpSameAsLabelEvaluate(node, options, virtualNode) {
  4. var labelText = labelVirtual(virtualNode),
  5. check = node.getAttribute('title');
  6. if (!labelText) {
  7. return false;
  8. }
  9. if (!check) {
  10. check = '';
  11. if (node.getAttribute('aria-describedby')) {
  12. var ref = idrefs(node, 'aria-describedby');
  13. check = ref
  14. .map(thing => {
  15. return thing ? accessibleText(thing) : '';
  16. })
  17. .join('');
  18. }
  19. }
  20. return sanitize(check) === sanitize(labelText);
  21. }
  22. export default helpSameAsLabelEvaluate;