link-in-text-block-matches.js 446 B

123456789101112131415161718192021
  1. import { sanitize } from '../commons/text';
  2. import { isVisible, isInTextBlock } from '../commons/dom';
  3. function linkInTextBlockMatches(node) {
  4. var text = sanitize(node.textContent);
  5. var role = node.getAttribute('role');
  6. if (role && role !== 'link') {
  7. return false;
  8. }
  9. if (!text) {
  10. return false;
  11. }
  12. if (!isVisible(node, false)) {
  13. return false;
  14. }
  15. return isInTextBlock(node);
  16. }
  17. export default linkInTextBlockMatches;