Optimize hasSlot selector

pull/189/head
Cory LaViska 2020-08-27 16:30:45 -04:00
rodzic 83825d899d
commit 8e94f9fa9e
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -40,5 +40,5 @@ export function getTextContent(slot: HTMLSlotElement): string {
// 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;
return el.querySelector(`[slot="${name}"]`) !== null;
}