@laserware/dominator
    Preparing search index...

    Function selectAttributes

    • Attempts to build a CSS selector string from the attributes object. Note that the values of the attributes object are coerced to a string, and null excludes a value but only includes a name. If tagName is specified, it is included in the resulting selector.

      Note

      If you specify the optional E generic, you'll get autocomplete on the attributes for the element associated with that type.

      Type Parameters

      Parameters

      • attributes: Attributes<E>

        Object with a key of attribute name and value of attribute value.

      • OptionaltagName: string

        Optional tagName name to include in the selector.

      Returns string

      CSS selector based on the attributes.

      InvalidAttributeError if a value in attributes could not be stringified.

      Single Entry With Value

      selectAttributes({ disabled: true });
      // [disabled="true"]

      Single Entry With Value and Tag

      selectAttributes({ disabled: true }, "button");
      // button[disabled="true"]

      Single Entry Without Value

      selectAttributes({ inert: null });
      // [inert]

      Multiple Entries

      selectAttributes({ disabled: true, inert: null });
      // [disabled="true"][inert]