How to use the aria-query.roles 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 makuga01 / dnsFookup / FE / node_modules / eslint-plugin-jsx-a11y / lib / util / isInteractiveRole.js View on Github external
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _ariaQuery = require("aria-query");

var _jsxAstUtils = require("jsx-ast-utils");

var _arrayIncludes = _interopRequireDefault(require("array-includes"));

var roles = (0, _toConsumableArray2["default"])(_ariaQuery.roles.keys());
var interactiveRoles = roles.filter(function (name) {
  return !_ariaQuery.roles.get(name)["abstract"];
}).filter(function (name) {
  return _ariaQuery.roles.get(name).superClass.some(function (klasses) {
    return (0, _arrayIncludes["default"])(klasses, 'widget');
  });
}); // 'toolbar' does not descend from widget, but it does support
// aria-activedescendant, thus in practice we treat it as a widget.

interactiveRoles.push('toolbar');
/**
 * Returns boolean indicating whether the given element has a role
 * that is associated with an interactive component. Used when an element
 * has a dynamic handler on it and we need to discern whether or not
 * its intention is to be interacted with in the DOM.
 *
github makuga01 / dnsFookup / FE / node_modules / eslint-plugin-jsx-a11y / lib / util / isInteractiveRole.js View on Github external
}).filter(function (name) {
  return _ariaQuery.roles.get(name).superClass.some(function (klasses) {
    return (0, _arrayIncludes["default"])(klasses, 'widget');
  });
}); // 'toolbar' does not descend from widget, but it does support
// aria-activedescendant, thus in practice we treat it as a widget.
github makuga01 / dnsFookup / FE / node_modules / eslint-plugin-jsx-a11y / lib / util / isInteractiveElement.js View on Github external
exports["default"] = void 0;

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _ariaQuery = require("aria-query");

var _axobjectQuery = require("axobject-query");

var _arrayIncludes = _interopRequireDefault(require("array-includes"));

var _attributesComparator = _interopRequireDefault(require("./attributesComparator"));

var domKeys = (0, _toConsumableArray2["default"])(_ariaQuery.dom.keys());
var roleKeys = (0, _toConsumableArray2["default"])(_ariaQuery.roles.keys());
var elementRoleEntries = (0, _toConsumableArray2["default"])(_ariaQuery.elementRoles);
var nonInteractiveRoles = new Set(roleKeys.filter(function (name) {
  var role = _ariaQuery.roles.get(name);

  return !role["abstract"] && !role.superClass.some(function (classes) {
    return (0, _arrayIncludes["default"])(classes, 'widget');
  });
}));
var interactiveRoles = new Set([].concat(roleKeys, // 'toolbar' does not descend from widget, but it does support
// aria-activedescendant, thus in practice we treat it as a widget.
'toolbar').filter(function (name) {
  var role = _ariaQuery.roles.get(name);

  return !role["abstract"] && role.superClass.some(function (classes) {
    return (0, _arrayIncludes["default"])(classes, 'widget');
  });
github makuga01 / dnsFookup / FE / node_modules / eslint-plugin-jsx-a11y / lib / rules / role-supports-aria-props.js View on Github external
JSXOpeningElement: function JSXOpeningElement(node) {
        // If role is not explicitly defined, then try and get its implicit role.
        var type = (0, _jsxAstUtils.elementType)(node);
        var role = (0, _jsxAstUtils.getProp)(node.attributes, 'role');
        var roleValue = role ? (0, _jsxAstUtils.getLiteralPropValue)(role) : (0, _getImplicitRole["default"])(type, node.attributes);
        var isImplicit = roleValue && role === undefined; // If there is no explicit or implicit role, then assume that the element
        // can handle the global set of aria-* properties.
        // This actually isn't true - should fix in future release.

        if (typeof roleValue !== 'string' || _ariaQuery.roles.get(roleValue) === undefined) {
          return;
        } // Make sure it has no aria-* properties defined outside of its property set.


        var _roles$get = _ariaQuery.roles.get(roleValue),
            propKeyValues = _roles$get.props;

        var propertySet = Object.keys(propKeyValues);
        var invalidAriaPropsForRole = (0, _toConsumableArray2["default"])(_ariaQuery.aria.keys()).filter(function (attribute) {
          return propertySet.indexOf(attribute) === -1;
        });
        node.attributes.forEach(function (prop) {
          // Ignore the attribute if its value is null or undefined.
          if ((0, _jsxAstUtils.getPropValue)(prop) == null) return; // Ignore the attribute if it's a spread.

          if (prop.type === 'JSXSpreadAttribute') return;
github makuga01 / dnsFookup / FE / node_modules / eslint-plugin-jsx-a11y / lib / rules / role-has-required-aria-props.js View on Github external
var validRoles = normalizedValues.filter(function (val) {
          return (0, _toConsumableArray2["default"])(_ariaQuery.roles.keys()).indexOf(val) > -1;
        }); // Check semantic DOM elements
        // For example, <input role="switch" type="checkbox">
github makuga01 / dnsFookup / FE / node_modules / eslint-plugin-jsx-a11y / lib / util / isInteractiveElement.js View on Github external
var nonInteractiveRoles = new Set(roleKeys.filter(function (name) {
  var role = _ariaQuery.roles.get(name);

  return !role["abstract"] && !role.superClass.some(function (classes) {
    return (0, _arrayIncludes["default"])(classes, 'widget');
  });
}));
var interactiveRoles = new Set([].concat(roleKeys, // 'toolbar' does not descend from widget, but it does support
github claykohut / ethtxt / node_modules / eslint-plugin-jsx-a11y / lib / util / isInteractiveElement.js View on Github external
var nonInteractiveRoles = new Set(roleKeys.filter(function (name) {
  var role = _ariaQuery.roles.get(name);
  return !role.abstract && !role.superClass.some(function (classes) {
    return (0, _arrayIncludes2.default)(classes, 'widget');
  });
}));
github flaviuse / mern-authentication / client / node_modules / eslint-plugin-jsx-a11y / lib / rules / role-has-required-aria-props.js View on Github external
validRoles.forEach(function (role) {
          var _roles$get = _ariaQuery.roles.get(role),
              requiredPropKeyValues = _roles$get.requiredProps;

          var requiredProps = Object.keys(requiredPropKeyValues);

          if (requiredProps.length > 0) {
            var hasRequiredProps = requiredProps.every(function (prop) {
              return (0, _jsxAstUtils.getProp)(attribute.parent.attributes, prop);
            });
            if (hasRequiredProps === false) {
              context.report({
                node: attribute,
                message: errorMessage(role.toLowerCase(), requiredProps)
              });
            }
          }
        });
github makuga01 / dnsFookup / FE / node_modules / eslint-plugin-jsx-a11y / lib / util / getImplicitRole.js View on Github external
function getImplicitRole(type, attributes) {
  var implicitRole;

  if (_implicitRoles["default"][type]) {
    implicitRole = _implicitRoles["default"][type](attributes);
  }

  if (_ariaQuery.roles.has(implicitRole)) {
    return implicitRole;
  }

  return null;
}
github claykohut / ethtxt / node_modules / eslint-plugin-jsx-a11y / lib / rules / role-has-required-aria-props.js View on Github external
var validRoles = normalizedValues.filter(function (val) {
          return [].concat(_toConsumableArray(_ariaQuery.roles.keys())).indexOf(val) > -1;
        });