@query
Converts a class property into a getter that runsquerySelector on the element’s renderRoot.
Import
Signature
A CSS selector string passed to
renderRoot.querySelector().When
true, the query result is cached after the first non-null lookup.
Subsequent reads return the cached value without querying the DOM again.
Only use this when you know the queried element will not change after
initial render.Return type
Element | null
Example
@queryAll
Converts a class property into a getter that runsquerySelectorAll on the element’s renderRoot.
Import
Signature
A CSS selector string passed to
renderRoot.querySelectorAll().Return type
NodeListOf<Element>
Example
@queryAsync
Converts a class property into a getter that returns aPromise resolving to the result of querySelector
after the element’s next update completes.
Useful when the queried element’s presence depends on reactive state that may not have been rendered yet.
Import
Signature
A CSS selector string passed to
renderRoot.querySelector(), evaluated after
updateComplete resolves.Return type
Promise<Element | null>
Example
@queryAssignedElements
Converts a class property into a getter that returns the elements assigned to a slot usingHTMLSlotElement.assignedElements().
Import
Signature
Options
Name of the slot to query. Omit to query the default (unnamed) slot.
When
true, recursively returns elements from nested slots.
Passed directly to HTMLSlotElement.assignedElements({flatten}).A CSS selector to filter the assigned elements. Only elements matching
this selector are included in the result.
Return type
Array<Element>
Example
@queryAssignedNodes
Converts a class property into a getter that returns the nodes assigned to a slot usingHTMLSlotElement.assignedNodes().
Includes text nodes; use @queryAssignedElements if you only need element nodes.
Import
Signature
Options
Name of the slot to query. Omit to query the default (unnamed) slot.
When
true, recursively returns nodes from nested slots.
Passed directly to HTMLSlotElement.assignedNodes({flatten}).Return type
Array<Node>