MCPcopy Create free account
hub / github.com/UI5/webcomponents / getSlotName

Function getSlotName

packages/base/src/util/SlotsHelper.ts:6–21  ·  view source on GitHub ↗
(node: Node)

Source from the content-addressed store, hash-verified

4 * @returns {string}
5 */
6const getSlotName = (node: Node) => {
7 // Text nodes can only go to the default slot
8 if (!(node instanceof HTMLElement)) {
9 return "default";
10 }
11
12 // Discover the slot based on the real slot name (f.e. footer => footer, or content-32 => content)
13 const slot = node.getAttribute("slot");
14 if (slot) {
15 const match = slot.match(/^(.+?)-\d+$/);
16 return match ? match[1] : slot;
17 }
18
19 // Use default slot as a fallback
20 return "default";
21};
22
23const getSlottedNodes = (node: Node) => {
24 if (node instanceof HTMLSlotElement) {

Callers 1

_updateSlotsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…