no-focusable-content-evaluate.js 699 B

1234567891011121314151617181920212223242526272829303132333435
  1. import isFocusable from '../../commons/dom/is-focusable';
  2. function focusableDescendants(vNode) {
  3. if (isFocusable(vNode)) {
  4. return true;
  5. }
  6. if (!vNode.children) {
  7. if (vNode.props.nodeType === 1) {
  8. throw new Error('Cannot determine children');
  9. }
  10. return false;
  11. }
  12. return vNode.children.some(child => {
  13. return focusableDescendants(child);
  14. });
  15. }
  16. function noFocusbleContentEvaluate(node, options, virtualNode) {
  17. if (!virtualNode.children) {
  18. return undefined;
  19. }
  20. try {
  21. return !virtualNode.children.some(child => {
  22. return focusableDescendants(child);
  23. });
  24. } catch (e) {
  25. return undefined;
  26. }
  27. }
  28. export default noFocusbleContentEvaluate;