(node: Node)
| 4 | * @returns {string} |
| 5 | */ |
| 6 | const 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 | |
| 23 | const getSlottedNodes = (node: Node) => { |
| 24 | if (node instanceof HTMLSlotElement) { |
no outgoing calls
no test coverage detected
searching dependent graphs…