mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
Remove audit role that depends on CJS package (#9293)
* Remove audit role that depends on CJS package * Adding changeset --------- Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
parent
e88f166be8
commit
cf5fa43762
4 changed files with 7 additions and 69 deletions
7
.changeset/tender-eagles-learn.md
Normal file
7
.changeset/tender-eagles-learn.md
Normal file
|
@ -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.
|
|
@ -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",
|
||||
|
|
|
@ -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<string, string> {
|
|||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('aria-query').ARIARoleDefinitionKey} role
|
||||
* @param {string} tag_name
|
||||
* @param {Map<string, import('#compiler').Attribute>} attribute_map
|
||||
*/
|
||||
function is_semantic_role_element(
|
||||
role: string,
|
||||
tag_name: string,
|
||||
attributes: Record<string, string>
|
||||
) {
|
||||
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;
|
||||
}
|
||||
|
|
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue