Type Alias PropertySearch<K, V>

PropertySearch: K[] | PropertyFilter<K, V>

Search criteria that can be used to determine if a DOM property is present on an element. If an array, only the presence of the property names are checked. If an object, the property name and value are checked.

To check for the existence of a property only (i.e. you don't care what the value is), use null for the field.

Type Parameters

  • K extends string

    Key of the property to search.

  • V

    Type of the value to search for (only needed if using PropertyFilter).

HTML

<button id="example" aria-hidden="true" aria-label="Example">
Example
</button>

Code

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

const result = hasAllAttributes(element, {
"aria-hidden": true,
// Setting to null means "only check if property exists"
"aria-label": null,
});
// true