Wrapper for managing the dataset property on an element.
Valid shape for dataset property.
The values can be any type that can be stringified. Used for defining the shape
in the DatasetWrapper class.
Valid key/value pair representing dataset attributes/properties (prior to stringifying).
The key should be a valid DatasetKey and the value must be a valid
DatasetValue. Some values may be null or undefined.
Valid name for dataset data-* attributes
on a HTML/SVG element (e.g. data-some-value).
Valid name for Dataset entries. Represents either a key for the
HTMLElement.dataset property
or a name for the data-* attribute.
Valid type for the key of HTMLElement.dataset property entries in HTML/SVG elements.
Search criteria for checking if dataset entries are present in an element.
You can use an array of dataset property/attribute names to check only if the
dataset entries are present or an object to search for specific values.
Use null for the value if you only care about the presence of a dataset entry.
Value that can be assigned to or extracted from a dataset property (prior to stringifying).
Builds an object with the values associated with the dataset keys on the
target. If any of the specified keys don't exist, they are set to undefined
in the return value.
Attempts to get the value associated with the dataset attribute/property name
key on the target. Returns undefined if no entry was found for the
specified key.
Checks if the target has all of the dataset entries that match the
search criteria.
Returns true if the target has a dataset entry with key and optionally,
the matching value.
Checks if the target has some of the dataset entries that match the
search criteria.
Removes the dataset entries with the attribute/property names keys from the
target.
Removes the dataset entry with attribute/property name key from the target.
Attempts to build a CSS selector string for the specified dataset object. Note
that the values of the dataset object are coerced to a string, and null excludes
a value but only includes a key. If tagName is specified, it is included in
the resulting selector.
Attempts to build a valid selector for a dataset with the specified key and
optional value. If tagName is specified, it is included in the resulting
selector.
Assigns the dataset key/value pairs to the target.
Assigns the value to the dataset attribute/property name key in the target.
Creates a new DatasetWrapper instance for managing the
dataset
property on the target element. Optionally pass in initialData
that can fully or partially match the shape specified in the DS generic.
This module provides functions for querying and manipulating the dataset entries on HTML and SVG elements.