Skip to content

Commit c8e264b

Browse files
authored
Merge branch 'main' into html-string-literals
2 parents 825b08e + 8088622 commit c8e264b

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NodeComponent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ export abstract class NodeComponent<T extends Node> {
8585

8686
/**
8787
* Render this component in the place of a `<slot name="…"></slot>`.
88-
* If multiple slots with the same name are found, they will all be used.
88+
* @throws {@link !DOMException} When the slot is not found
8989
* @param slot The slot name
9090
* @param [parent] The parent element within to search for slots. Defaults to `document`
9191
*/
9292
public slot(slot: string, parent: ParentNode = document) {
93-
const slotNodes = parent.querySelectorAll(`slot[name="${slot}"]`);
94-
for (const slotNode of slotNodes)
95-
slotNode.replaceWith(this.node);
93+
const slotNode = parent.querySelector(`slot[name="${slot}"]`);
94+
if (slotNode === null) throw new DOMException(`Could not find slot "${slot}"`);
95+
slotNode.replaceWith(this.node);
9696
return this;
9797
}
9898

0 commit comments

Comments
 (0)