diff --git a/.changeset/spotty-cobras-warn.md b/.changeset/spotty-cobras-warn.md new file mode 100644 index 0000000000..26fc9e537d --- /dev/null +++ b/.changeset/spotty-cobras-warn.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes an issue where audit fails to initialize when encountered `` inside `` diff --git a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/a11y.ts b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/a11y.ts index 3bd296589f..45b94b31f6 100644 --- a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/a11y.ts +++ b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/a11y.ts @@ -338,8 +338,8 @@ export const a11y: AuditRuleWithSelector[] = [ selector: a11y_required_content.join(','), match(element: HTMLElement) { // innerText is used to ignore hidden text - const innerText = element.innerText.trim(); - if (innerText !== '') return false; + const innerText = element.innerText?.trim(); + if (innerText && innerText !== '') return false; // Check for aria-label const ariaLabel = element.getAttribute('aria-label')?.trim();