HtmlElementLike
Metadata callbacks receive an HtmlElementLike representing the element being evaluated.
It exposes a subset of the browser element API.
closest() method
Finds the element itself or its nearest matching ancestor.
Syntax
closest(selectors: string): HtmlElementLike | null | undefined
Return value
The element itself or its nearest matching ancestor, or null/undefined if none matches.
Parameters
selectors: Selector list to match.
getAttribute() method
Returns the value of the named attribute, or a nullish value if the attribute is absent.
Dynamic attributes may return a DynamicValue.
Syntax
getAttribute(name: string): string | DynamicValue | null | undefined
Return value
The attribute value, a DynamicValue for dynamic attributes, or null/undefined if absent.
Parameters
name: Attribute name.
hasAttribute() method
Returns whether the named attribute is present.
Syntax
hasAttribute(name: string): boolean
Return value
true if the attribute is present, otherwise false.
Parameters
name: Attribute name.
matches() method
- since: 11.23.0
Tests whether this element matches the selector list, including selectors that describe its context (for example, section > my-component).
Syntax
matches(selectors: string): boolean
Return value
true if this element matches the selector list, otherwise false.
Parameters
selectors: Selector list to match against this element.