summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/spotty-cobras-warn.md5
-rw-r--r--packages/astro/src/runtime/client/dev-toolbar/apps/audit/a11y.ts4
2 files changed, 7 insertions, 2 deletions
diff --git a/.changeset/spotty-cobras-warn.md b/.changeset/spotty-cobras-warn.md
new file mode 100644
index 000000000..26fc9e537
--- /dev/null
+++ b/.changeset/spotty-cobras-warn.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fixes an issue where audit fails to initialize when encountered `<a>` inside `<svg>`
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 3bd296589..45b94b31f 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();