semantic-role.js 612 B

123456789101112131415161718192021222324
  1. import fromPrimative from './from-primative';
  2. import getRole from '../aria/get-role';
  3. /**
  4. * Check if a virtual node matches an semantic role(s)
  5. *``
  6. * Note: matches.semanticRole(vNode, matcher) can be indirectly used through
  7. * matches(vNode, { semanticRole: matcher })
  8. *
  9. * Example:
  10. * ```js
  11. * matches.semanticRole(vNode, ['combobox', 'textbox']);
  12. * matches.semanticRole(vNode, 'combobox');
  13. * ```
  14. *
  15. * @param {VirtualNode} vNode
  16. * @param {Object} matcher
  17. * @returns {Boolean}
  18. */
  19. function semanticRole(vNode, matcher) {
  20. return fromPrimative(getRole(vNode), matcher);
  21. }
  22. export default semanticRole;