diff --git a/.changeset/tender-eagles-learn.md b/.changeset/tender-eagles-learn.md new file mode 100644 index 000000000000..b1f98c2f6c58 --- /dev/null +++ b/.changeset/tender-eagles-learn.md @@ -0,0 +1,7 @@ +--- +'astro': patch +--- + +Removes the 'a11y-role-has-required-aria-props' audit rule + +This audit rule depends on a CommonJS module. To prevent blocking the 4.0 release the rule is being removed temporarily. diff --git a/packages/astro/package.json b/packages/astro/package.json index f58b2c838cbb..074f50343902 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -125,7 +125,6 @@ "@types/babel__core": "^7.20.4", "acorn": "^8.11.2", "aria-query": "^5.3.0", - "axobject-query": "^4.0.0", "boxen": "^7.1.1", "chokidar": "^3.5.3", "ci-info": "^4.0.0", diff --git a/packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts b/packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts index fd3763564bca..5527689e34d5 100644 --- a/packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts +++ b/packages/astro/src/runtime/client/dev-overlay/plugins/audit/a11y.ts @@ -26,8 +26,6 @@ import type { ARIARoleDefinitionKey } from 'aria-query'; import { aria, roles } from 'aria-query'; import type { AuditRuleWithSelector } from './index.js'; -// @ts-expect-error package does not provide types -import { AXObjectRoles, elementAXObjects } from 'axobject-query'; const a11y_required_attributes = { a: ['href'], @@ -437,32 +435,6 @@ export const a11y: AuditRuleWithSelector[] = [ 'This will move elements out of the expected tab order, creating a confusing experience for keyboard users.', selector: '[tabindex]:not([tabindex="-1"]):not([tabindex="0"])', }, - { - code: 'a11y-role-has-required-aria-props', - title: 'Missing attributes required for ARIA role', - message: (element) => { - const { __astro_role: role, __astro_missing_attributes: required } = element as any; - return `${ - element.localName - } element is missing required attributes for its role (${role}): ${required.join(', ')}`; - }, - selector: '*', - match(element) { - const role = getRole(element); - if (!role) return false; - if (is_semantic_role_element(role, element.localName, getAttributeObject(element))) { - return; - } - const { requiredProps } = roles.get(role)!; - const required_role_props = Object.keys(requiredProps); - const missingProps = required_role_props.filter((prop) => !element.hasAttribute(prop)); - if (missingProps.length > 0) { - (element as any).__astro_role = role; - (element as any).__astro_missing_attributes = missingProps; - return true; - } - }, - }, { code: 'a11y-role-supports-aria-props', title: 'Unsupported ARIA attribute', @@ -595,34 +567,3 @@ function getAttributeObject(element: Element): Record { } return obj; } - -/** - * @param {import('aria-query').ARIARoleDefinitionKey} role - * @param {string} tag_name - * @param {Map} attribute_map - */ -function is_semantic_role_element( - role: string, - tag_name: string, - attributes: Record -) { - for (const [schema, ax_object] of elementAXObjects.entries()) { - if ( - schema.name === tag_name && - (!schema.attributes || - schema.attributes.every((attr: any) => attributes[attr.name] === attr.value)) - ) { - for (const name of ax_object) { - const axRoles = AXObjectRoles.get(name); - if (axRoles) { - for (const { name: _name } of axRoles) { - if (_name === role) { - return true; - } - } - } - } - } - } - return false; -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d989cfebf34..091179a0d54b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -511,9 +511,6 @@ importers: aria-query: specifier: ^5.3.0 version: 5.3.0 - axobject-query: - specifier: ^4.0.0 - version: 4.0.0 boxen: specifier: ^7.1.1 version: 7.1.1 @@ -8371,12 +8368,6 @@ packages: dependencies: dequal: 2.0.3 - /axobject-query@4.0.0: - resolution: {integrity: sha512-+60uv1hiVFhHZeO+Lz0RYzsVHy5Wr1ayX0mwda9KPDVLNJgZ1T9Ny7VmFbLDzxsH0D87I86vgj3gFrjTJUYznw==} - dependencies: - dequal: 2.0.3 - dev: false - /b4a@1.6.4: resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==} requiresBuild: true