mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
Add hasSlot utility
This commit is contained in:
@@ -35,3 +35,10 @@ export function getTextContent(slot: HTMLSlotElement): string {
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//
|
||||
// Determines whether a slot with the given name exists in an element.
|
||||
//
|
||||
export function hasSlot(el: HTMLElement, name: string) {
|
||||
return [...el.querySelectorAll('[slot]')].filter((slottedEl: HTMLSlotElement) => slottedEl.slot === name).length > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user