Check if a JSX element's text content (recursive) contains the given text. * Uses whitespace-normalized comparison because React collapses JSX whitespace * (newlines → spaces) but the AST retains raw formatting.
(node: any, text: string)
| 228 | * Uses whitespace-normalized comparison because React collapses JSX whitespace |
| 229 | * (newlines → spaces) but the AST retains raw formatting. */ |
| 230 | function containsText(node: any, text: string): boolean { |
| 231 | const normalized = normalizeWs(text.trim()); |
| 232 | if (!normalized) return false; |
| 233 | const children = node.children; |
| 234 | if (!children) return false; |
| 235 | for (const child of children) { |
| 236 | if (child.type === "JSXText" && normalizeWs(child.value.trim()).includes(normalized)) return true; |
| 237 | if (child.type === "JSXElement" && containsText(child, text)) return true; |
| 238 | } |
| 239 | return false; |
| 240 | } |
| 241 | |
| 242 | // ── Node resolution ────────────────────────────────────────────────────── |
| 243 |
no test coverage detected