* Clean label text - remove element's own value and extra whitespace
(labelElement, inputElement)
| 194 | * Clean label text - remove element's own value and extra whitespace |
| 195 | */ |
| 196 | function cleanLabelText(labelElement, inputElement) { |
| 197 | if (!labelElement) return ''; |
| 198 | |
| 199 | // Clone to avoid modifying the DOM |
| 200 | const clone = labelElement.cloneNode(true); |
| 201 | |
| 202 | // Remove the input element itself from the clone (for wrapping labels) |
| 203 | const inputInClone = clone.querySelector('input, select, textarea'); |
| 204 | if (inputInClone) { |
| 205 | inputInClone.remove(); |
| 206 | } |
| 207 | |
| 208 | // Get text and normalize whitespace |
| 209 | return clone.textContent?.replace(/\s+/g, ' ').trim() || ''; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Hybrid question text extraction for radio/checkbox |
no outgoing calls
no test coverage detected