MCPcopy Index your code
hub / github.com/InverseUI/InverseUI-Recorder / cleanLabelText

Function cleanLabelText

util/dom_utils.js:196–210  ·  view source on GitHub ↗

* Clean label text - remove element's own value and extra whitespace

(labelElement, inputElement)

Source from the content-addressed store, hash-verified

194 * Clean label text - remove element's own value and extra whitespace
195 */
196function 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

Callers 2

getLabelForElementFunction · 0.85
findQuestionTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected