diff --git a/internal/aria/aria.ts b/internal/aria/aria.ts index 22f2c7f4dd..25d289875f 100644 --- a/internal/aria/aria.ts +++ b/internal/aria/aria.ts @@ -7,12 +7,13 @@ /** * Accessibility Object Model reflective aria property name types. */ -export type ARIAProperty = Exclude; +export type ARIAProperty = keyof ARIAMixin; /** * Accessibility Object Model reflective aria properties. */ export const ARIA_PROPERTIES: ARIAProperty[] = [ + 'role', 'ariaAtomic', 'ariaAutoComplete', 'ariaBusy', @@ -72,7 +73,7 @@ export const ARIA_ATTRIBUTES = ARIA_PROPERTIES.map(ariaPropertyToAttribute); * @return True if the attribute is an aria attribute, or false if not. */ export function isAriaAttribute(attribute: string): attribute is ARIAAttribute { - return attribute.startsWith('aria-'); + return attribute.startsWith('aria-') || attribute === 'role'; } /** @@ -84,9 +85,7 @@ export function isAriaAttribute(attribute: string): attribute is ARIAAttribute { * @param property The aria property. * @return The aria attribute. */ -export function ariaPropertyToAttribute( - property: K, -) { +export function ariaPropertyToAttribute(property: K) { return ( property .replace('aria', 'aria-') @@ -101,8 +100,8 @@ type ARIAPropertyToAttribute = K extends `aria${infer Suffix}Element${infer OptS}` ? `aria-${Lowercase}` : K extends `aria${infer Suffix}` - ? `aria-${Lowercase}` - : K; + ? `aria-${Lowercase}` + : K; /** * An extension of `ARIAMixin` that enforces strict value types for aria diff --git a/internal/aria/aria_test.ts b/internal/aria/aria_test.ts index 7ae577f594..671668991b 100644 --- a/internal/aria/aria_test.ts +++ b/internal/aria/aria_test.ts @@ -22,8 +22,8 @@ describe('aria', () => { .toBeTrue(); }); - it('should return false for role', () => { - expect(isAriaAttribute('role')).withContext('role input').toBeFalse(); + it('should return true for role', () => { + expect(isAriaAttribute('role')).withContext('role input').toBeTrue(); }); it('should return false for non-aria attributes', () => {