* Get the normalized text content of a JSX element recursively.
(node: any)
| 740 | * Get the normalized text content of a JSX element recursively. |
| 741 | */ |
| 742 | function getElementTextNormalized(node: any): string { |
| 743 | let text = ""; |
| 744 | const children = node.children; |
| 745 | if (!children) return text; |
| 746 | for (const child of children) { |
| 747 | if (child.type === "JSXText") { |
| 748 | text += normalizeWs(child.value); |
| 749 | } else if (child.type === "JSXElement") { |
| 750 | text += getElementTextNormalized(child); |
| 751 | } else if (child.type === "JSXExpressionContainer") { |
| 752 | const expr = child.expression; |
| 753 | if (expr?.type === "StringLiteral" || expr?.type === "Literal") { |
| 754 | text += String(expr.value ?? ""); |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | return text; |
| 759 | } |
| 760 | |
| 761 | function getLineStarts(source: string): number[] { |
| 762 | const starts = [0]; |
nothing calls this directly
no test coverage detected