@laserware/dominator
    Preparing search index...

    Function setDatasetEntry

    • Assigns the value to the dataset attribute/property name key in the target.

      Type Parameters

      Parameters

      • target: null | Target

        Element, EventTarget, or CSS selector.

      • key: string

        Key or property name for the dataset entry.

      • value: null | DatasetValue

        Value to set for associated property or attribute name.

      Returns E

      Element representation of the specified target.

      elements!InvalidElementError if the specified target wasn't found.

      HTML (Before)

      <div
      id="example"
      data-is-active="false"
      data-count="30"
      data-label="Example"
      >
      ...
      </div>

      Using Attribute Name (data-*)

      const element = findElement("#example")!;

      setDatasetEntry(element, "data-is-active", true);
      setDatasetEntry(element, "data-count", 50);
      setDatasetEntry(element, "data-label", "Update");

      Using Property Name (camelCase)

      const element = findElement("#example")!;

      setDatasetEntry(element, "isActive", true);
      setDatasetEntry(element, "count", 50);
      setDatasetEntry(element, "label", "Update");

      HTML (After)

      <div
      id="example"
      data-is-active="true"
      data-count="50"
      data-label="Update"
      >
      ...
      </div>