• Checks if the target has some of the attributes that match the search criteria.

    Type Parameters

    • TN extends TagName = "*"

      Tag name of the Element representation of target.

    Parameters

    • target: null | Target<TN>

      Element, EventTarget, or CSS selector.

    • search: AttributesSearch<TN>

      Array of attribute names or attributes filter object to check for.

    Returns boolean

    true if the target matches some search criteria.

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

    HTML

    <div id="example" aria-hidden="true" inert>Example</div>
    

    Code

    Note that the aria-label attribute isn't present on the div above, but the function still returns true:

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

    hasSomeAttributes(element, ["aria-hidden", "aria-label"]);
    // true

    hasSomeAttributes(element, {
    inert: null,
    "aria-hidden": true,
    "aria-label": "Click Me",
    });
    // true