update hasSlot selector to search top-level only (#481)

This commit is contained in:
Shanyu Cui
2021-07-16 05:28:47 -07:00
committed by GitHub
parent 3541540d84
commit e36a49b635

View File

@@ -43,7 +43,7 @@ export function getTextContent(slot: HTMLSlotElement): string {
export function hasSlot(el: HTMLElement, name?: string) {
// Look for a named slot
if (name) {
return el.querySelector(`[slot="${name}"]`) !== null;
return el.querySelector(`:scope > [slot="${name}"]`) !== null;
}
// Look for a default slot