@jossmac/lil-libs
    Preparing search index...

    Function querySelector

    • Thin wrapper around Element.querySelector() that qualifies the returned value as an HTMLElement.

      • el: Maybe<HTMLElement>

        Root element to search within. Returns null when el is nullish.

      • selector: string

        CSS selector passed to Element.querySelector.

      The first matching HTMLElement, or null if none is found or the match is not an HTMLElement (e.g. SVG elements).

      const container = document.createElement("div");
      container.innerHTML = "<button>Save</button><svg><circle /></svg>";

      querySelector(container, "button"); // HTMLButtonElement
      querySelector(container, "circle"); // null (non-HTMLElement)
      querySelector(null, "button"); // null