MAIDR JavaScript API
    Preparing search index...
    • Finds the element Mermaid drew for a node, by the id it was given.

      An id is <svg id>-<dom id> where the dom id usually ends in a counter (flowchart-A-0, classId-Animal-4, state-Still-3). The counter moves between the parse that drew the diagram and the parse the adapter reads, so an exact match is tried first and then a match on everything but the counter, with an optional type prefix. Each key is tried in turn, and for a key the first free element in document order wins.

      The candidates are indexed on the first call for a list and the index is reused by later calls with the same list, so the list must not change between them.

      Parameters

      • candidates: Element[]

        The elements that could be nodes, in document order

      • svgId: string

        The diagram's id prefix

      • keys: (string | undefined)[]

        The node's dom id and id, most specific first

      • used: Set<Element>

        Elements already paired, which are not paired twice

      Returns Element | null

      The element, or null