( element: HTMLElement, maxAncestors = 10 )
| 778 | * @returns Source location result |
| 779 | */ |
| 780 | export function findNearestComponentSource( |
| 781 | element: HTMLElement, |
| 782 | maxAncestors = 10 |
| 783 | ): SourceLocationResult { |
| 784 | let current: HTMLElement | null = element; |
| 785 | let depth = 0; |
| 786 | |
| 787 | while (current && depth < maxAncestors) { |
| 788 | const result = getSourceLocation(current); |
| 789 | |
| 790 | // Return first successful result |
| 791 | if (result.found) { |
| 792 | return result; |
| 793 | } |
| 794 | |
| 795 | // If we found fiber but no source, keep looking up DOM |
| 796 | // (might find a parent component with source info) |
| 797 | current = current.parentElement; |
| 798 | depth++; |
| 799 | } |
| 800 | |
| 801 | // Return result for original element (will explain why not found) |
| 802 | return getSourceLocation(element); |
| 803 | } |
| 804 | |
| 805 | /** |
| 806 | * Gets all component sources in the ancestor chain |
no test coverage detected
searching dependent graphs…