0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-20 22:12:38 -05:00

Fix an issue where audit fails to initialize when encountered <a> inside <svg> (#10163)

* Fix an issue where audit fails to initialize when encountered `<a>` inside `<svg>`

* Add changeset
This commit is contained in:
Ming-jun Lu 2024-02-20 18:22:05 +08:00 committed by GitHub
parent d50dddb71d
commit b92d35f102
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"astro": patch
---
Fixes an issue where audit fails to initialize when encountered `<a>` inside `<svg>`

View file

@ -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();