Tag name of Element to select attributes from.
Object with key of attribute name and value of attribute value.
Optional
tagName: TagNameOptional tagName name to include in the selector.
CSS selector based on the attributes
.
InvalidAttributeError
if a value in attributes
could not be stringified.
Single Entry With Value
selectAttributes({ disabled: true });
// [disabled="true"]
Single Entry With Value and Tag
selectAttributes({ disabled: true }, "button");
// button[disabled="true"]
Single Entry Without Value
selectAttributes({ inert: null });
// [inert]
Multiple Entries
selectAttributes({ disabled: true, inert: null });
// [disabled="true"][inert]
Attempts to build a CSS selector string from the
attributes
object. Note that the values of theattributes
object are coerced to a string andnull
excludes a value but only includes a name. IftagName
is specified, it is included in the resulting selector.If you specify the optional
TN
(tag name) generic, you'll get autocomplete on the attributes for the Element associated with that tag name.