geoview-core - v2.2.0
    Preparing search index...

    Function enhanceLinksAccessibility

    • Enhances links accessibility by adding screen reader announcements for external links.

      Uses DOM parsing to safely inject visually-hidden span elements with announcement text for screen readers.

      Security Note: This function does NOT sanitize output. Callers MUST sanitize the result using sanitizeHtmlContent() before rendering to prevent XSS risks.

      Parameters

      • html: string

        HTML string containing links (typically from linkifyHtml)

      • announcementText: string

        Translated announcement text for screen readers (e.g., "opens in new tab")

      Returns string

      HTML string with visually-hidden accessibility announcements injected into external links, or the original HTML if parsing fails

      Input: '<a href="..." target="_blank">View</a>'
      Output: '<a href="..." target="_blank">View <span class="visually-hidden"> (opens in new tab)</span></a>'