UMD Web Utilities Library
    Preparing search index...

    Function wrapLinkForAnimation

    • Wraps link content in a span element for animation purposes

      Checks if a link's content is already wrapped in a span, and if not, wraps it. Skips slot content to avoid interfering with web component content distribution. This is useful for CSS animations that target the span within links.

      Parameters

      • element: { element: HTMLElement | HTMLAnchorElement }

        The element containing the link, or the link itself

      Returns void

      const link = document.createElement('a');
      link.href = '#';
      link.textContent = 'Click me';

      wrapLinkForAnimation({ element: link });
      // Result: <a href="#"><span>Click me</span></a>