How to use the aria-query.dom.get 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 / aria-role.js View on Github external
"VAttribute" (node) {
        const options = context.options[0] || {};
        const ignoreNonDOM = !!options.ignoreNonDOM;
        if (ignoreNonDOM) {
          const type = utils.getElementType(node.parent.parent);
          if (!dom.get(type)) {
            return;
          }
        }
        const isRole = utils.isAttribute(node, 'role')
        if (!isRole) { return; }

        const value = utils.getAttributeValue(node);
        if (value === null || typeof value !== 'string') {
          return;
        }
        const normalizedValues = String(value).toLowerCase().split(' ');
        const validRoles = [...roles.keys()].filter(role => roles.get(role).abstract === false);
        const isValid = normalizedValues.every(val => validRoles.indexOf(val) > -1);
        if (isValid === true) { return; }

        context.report({
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 / no-autofocus.js View on Github external
"VAttribute" (node) {
        const isAutofocus = utils.isAttribute(node, 'autofocus')

        if (!isAutofocus) {
          return;
        }
        const options = context.options[0] || {};
        const ignoreNonDOM = !!options.ignoreNonDOM;

        if (ignoreNonDOM) {
          const type = utils.getElementType(node.parent.parent);
          if (!dom.get(type)) {
            return;
          }
        }
        context.report({
          node,
          loc: node.loc,
          message: errorMessage
        });
      }
    }, JsxRule.create(context))