@mateothegreat/svelte5-router - 2.15.3
    Preparing search index...

    Function active

    • Add the active class to the node if the current route matches the node's href.

      Similar to route.

      Add use:active to an anchor element to manage active state.

      Parameters

      • node: HTMLAnchorElement

        The anchor element to handle.

      • options: Pick<RouteOptions, "active"> = {}

      Returns { destroy(): void }

      export const active = (node: HTMLAnchorElement, options: Pick<RouteOptions, "active"> = {}) => {
      let url = urls.parse(node.href);

      const apply = () => {
      applyActiveClass(url, options, node);
      };

      apply();

      window.addEventListener("pushState", apply);

      return {
      destroy() {
      window.removeEventListener("pushState", apply);
      }
      };
      };