buildQuickSelector function presentation ✓ 100.0%
Last updated: 2026-03-05T11:49:57.418Z
Metrics
LOC: 24
Complexity: 7
Params: 1
Coverage: 100.0% (13/13 lines, 0x executed)
Signature
buildQuickSelector(el: Element): : string
Source Code
function buildQuickSelector(el: Element): string {
if (el.id) return `#${CSS.escape(el.id)}`;
const testId =
el.getAttribute("data-testid") ?? el.getAttribute("data-test-id");
if (testId) return `[data-testid="${CSS.escape(testId)}"]`;
const name = el.getAttribute("name");
if (name) return `${el.tagName.toLowerCase()}[name="${CSS.escape(name)}"]`;
const tag = el.tagName.toLowerCase();
// Stable semantic classes are more specific than attribute-based selectors
const stableClasses = getStableClasses(el);
if (stableClasses.length > 0) {
return `${tag}.${stableClasses.map((c) => CSS.escape(c)).join(".")}`;
}
const type = el.getAttribute("type");
if (type) return `${tag}[type="${CSS.escape(type)}"]`;
// Fallback: generate a unique CSS path from the DOM hierarchy
return buildCSSPath(el);
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| getStableClasses | calls |
| buildCSSPath | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| detectSubmitActions | calls |
| buildStep | calls |
| onInput | calls |
| onChange | calls |
| captureUnrecordedFormFields | calls |
| processMutations | calls |