• Checks if the target has all of the dataset entries that match the search criteria.

    Parameters

    • target: null | Target

      Element, EventTarget, or CSS selector.

    • search: DatasetSearch

      Array of dataset keys or dataset filter object to check for.

    Returns boolean

    true if the target matches all search criteria.

    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")!;

    hasAllDatasetEntries(element, ["data-is-active", "data-count"]);
    // true

    hasAllDatasetEntries(element, ["isActive", "data-missing"]);
    // false

    hasAllDatasetEntries(element, { "data-count", 30, "label": null });
    // true