(target: HTMLElement)
| 584 | * Supports elements inside shadow DOM by marking shadow boundary crossings. |
| 585 | */ |
| 586 | export function getFullElementPath(target: HTMLElement): string { |
| 587 | const parts: string[] = []; |
| 588 | let current: HTMLElement | null = target; |
| 589 | |
| 590 | while (current && current.tagName.toLowerCase() !== "html") { |
| 591 | const tag = current.tagName.toLowerCase(); |
| 592 | let identifier = tag; |
| 593 | |
| 594 | if (current.id) { |
| 595 | identifier = `${tag}#${current.id}`; |
| 596 | } else if (current.className && typeof current.className === "string") { |
| 597 | const cls = current.className |
| 598 | .split(/\s+/) |
| 599 | .map(c => c.replace(/[_][a-zA-Z0-9]{5,}.*$/, "")) |
| 600 | .find(c => c.length > 2); |
| 601 | if (cls) identifier = `${tag}.${cls}`; |
| 602 | } |
| 603 | |
| 604 | // Mark shadow boundary crossings |
| 605 | const nextParent = getParentElement(current); |
| 606 | if (!current.parentElement && nextParent) { |
| 607 | identifier = `⟨shadow⟩ ${identifier}`; |
| 608 | } |
| 609 | |
| 610 | parts.unshift(identifier); |
| 611 | current = nextParent as HTMLElement | null; |
| 612 | } |
| 613 | |
| 614 | return parts.join(" > "); |
| 615 | } |
no test coverage detected
searching dependent graphs…