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

Function findQuestionElementInContainer

util/dom_utils.js:260–282  ·  view source on GitHub ↗

* Find question element within a container

(container, inputElement)

Source from the content-addressed store, hash-verified

258 * Find question element within a container
259 */
260function findQuestionElementInContainer(container, inputElement) {
261 // Look for semantic elements that typically contain questions
262 const selectors = [
263 'label:not(:has(input))', // Labels that don't wrap inputs
264 '.question', '.label', '.prompt',
265 '[class*="label"]:not(input)',
266 'h3', 'h4', 'h5', 'p', 'span', 'div'
267 ];
268
269 for (const selector of selectors) {
270 try {
271 const el = container.querySelector(selector);
272 if (el && !el.contains(inputElement)) {
273 const text = el.textContent?.trim();
274 if (text && text.length > 10 && text.length < 500) {
275 return el;
276 }
277 }
278 } catch (e) { /* Skip invalid selectors */ }
279 }
280
281 return null;
282}
283
284/**
285 * DOM traversal fallback - look for text in ancestors/siblings

Callers 1

findQuestionTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected