How to use the aria-query.roles.keys function in aria-query

To help you get started, we’ve selected a few aria-query examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maranran / eslint-plugin-vue-a11y / lib / rules / role-has-required-aria-props.js View on Github external
"VStartTag" (node) {
        const element = node.parent;
        const type = utils.getElementType(element);
        const role = utils.getRoleValue(element)
        if (!role) {
          return
        }
        if (!dom.get(type)) {
          return;
        }
        const normalizedRoles = String(role).toLowerCase().split(' ');
        const roleArray = [...roles.keys()];
        const validRoles = normalizedRoles.filter(value => roleArray.indexOf(value) >  -1)
        validRoles.forEach((role) => {
          const { requiredProps: requiredPropKeyValues } = roles.get(role);
          const requiredProps = Object.keys(requiredPropKeyValues);

          if (requiredProps.length > 0) {
            const hasRequiredProps = requiredProps.every(prop => utils.getAttribute(element, prop) !== undefined)
            if (!hasRequiredProps) {
              context.report({
                node,
                message: errorMessage(role.toLowerCase(), requiredProps),
              });
            }
          }
        })
      }
github maranran / eslint-plugin-vue-a11y / lib / rules / aria-role.js View on Github external
        const validRoles = [...roles.keys()].filter(role => roles.get(role).abstract === false);
        const isValid = normalizedValues.every(val => validRoles.indexOf(val) > -1);
github maranran / eslint-plugin-vue-a11y / lib / utils / index.js View on Github external
const utils = require('eslint-plugin-vue/lib/utils');
const assert = require('assert');
const { roles, elementRoles, dom } = require('aria-query');
const rolesArray = [...roles.keys()];
const validRoles = rolesArray.filter(name => !roles.get(name).abstract)
const interactiveRoles = validRoles
  .filter(name => roles.get(name).superClass.some(klasses => klasses.indexOf('widget') !== -1));
interactiveRoles.push('toolbar');

const nonInteractiveRoles = validRoles
  .filter(name => !roles.get(name).superClass.some(klasses => klasses.indexOf('widget') !== -1));

const nonInteractiveElementRole = [...elementRoles].reduce((accumulator, [element, roles]) => {
  if ([...roles].every(role => nonInteractiveRoles.indexOf(role) !== -1)) {
    accumulator.push(element);
  }
  return accumulator;
  }, []);
const interactiveElementRole = [...elementRoles].reduce((accumulator, [element, roles]) => {
  if ([...roles].some(role => interactiveRoles.indexOf(role) !== -1)) {