The slot element containing the anchor elements
The first HTMLAnchorElement if found, null otherwise
// Single link in slot
// HTML: <div slot="actions"><a href="/learn-more">Learn More</a></div>
const actionSlot = element.querySelector('[slot="actions"]');
const link = getLinkFromSlot(actionSlot);
// Returns the anchor element
// Multiple links - removes extra parent elements
// HTML:
// <div slot="actions">
// <div><a href="/link1">Link 1</a></div>
// <div><a href="/link2">Link 2</a></div>
// </div>
const actionSlot = element.querySelector('[slot="actions"]');
const link = getLinkFromSlot(actionSlot);
// Logs warning, removes second div, returns first anchor
Retrieves the first anchor element from a slot element
Searches for anchor elements within the provided slot element and returns the first one found. If multiple links are detected, it removes the parent elements (direct children of the slot) that contain the additional links, keeping only the first link and its parent. This ensures components that only support a single link maintain proper DOM structure.