@laserware/dominator
    Preparing search index...

    Function hasDatasetEntry

    • Returns true if the target has a dataset entry with key and optionally, the matching value.

      Parameters

      • target: null | Target

        Element, EventTarget, or CSS selector.

      • key: string

        Property (e.g. someProperty) or attribute name (e.g. data-some-property) for the dataset entry.

      • Optionalvalue: DatasetValue

        Optional dataset value to check for.

      Returns boolean

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

      HTML

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

      Code

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

      hasDatasetEntry(element, "data-is-active");
      // true

      hasDatasetEntry(element, "isActive", "false");
      // false ("false" cannot be a string, must be the boolean value `false`)

      hasDatasetEntry(element, "data-count", 30);
      // true