Function querySelectorAll

  • This is a wrapper around document.querySelectorAll(). This is analogous to getById().

    This includes a lot of assertions. These have good error messages aimed at a developer. The assumption is that you will run this very early in the main program and store the results in a constant. If there is a problem we want to catch it ASAP.

    You can set the min and max number of elements. That's another thing that's good to check early. The default range is 1 - Infinity. Set min to 0 to completely disable this test.

    Type Parameters

    • T extends Element

    Parameters

    • selector: string

      What you are looking for. E.g. "[data-precisionIssues]"

    • ty: (new () => T)

      The expected type of the items. E.g. SVGTextElement

        • new (): T
        • Returns T

    • min: number = 1

      The minimum number of items allowed. Defaults to 1.

    • max: number = Infinity

      The maximum number of items allowed. Defaults to Infinity.

    • start: Pick<Document, "querySelectorAll"> = document

    Returns readonly T[]

    An array containing all of the objects that matches the selector.

    If we don't get the right number of objects or if any of the objects have the wrong type.