export function findAssignedElement(slot: HTMLSlotElement, selector: string): HTMLElement | null { if (!slot) { return null; } for (const node of slot.assignedNodes({ flatten: true, })) { if (node.nodeType === Node.ELEMENT_NODE) { const el = node as HTMLElement; if (el.matches(selector)) { return el; } } } return null; } export function findAssignedElements(slot: HTMLSlotElement, selector: string): HTMLSlotElement[] { const result: null | HTMLSlotElement[] = []; if (!slot) { return result; } for (const node of slot.assignedNodes({ flatten: true, })) { if (node.nodeType === Node.ELEMENT_NODE) { const el = node as HTMLSlotElement; if (el.matches(selector)) { result.push(el); } } } return result; }