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)

graph LR buildQuickSelector["buildQuickSelector"] getStableClasses["getStableClasses"] buildCSSPath["buildCSSPath"] buildQuickSelector -->|calls| getStableClasses buildQuickSelector -->|calls| buildCSSPath style buildQuickSelector fill:#dbeafe,stroke:#2563eb,stroke-width:2px click buildQuickSelector "077a2e134af1a6be.html" click getStableClasses "ea120245e0b8c28c.html" click buildCSSPath "2f2f3878eed47f3f.html"
TargetType
getStableClasses calls
buildCSSPath calls

Impact (Incoming)

graph LR buildQuickSelector["buildQuickSelector"] detectSubmitActions["detectSubmitActions"] buildStep["buildStep"] onInput["onInput"] onChange["onChange"] captureUnrecordedFormFields["captureUnrecordedFormFields"] processMutations["processMutations"] detectSubmitActions -->|calls| buildQuickSelector buildStep -->|calls| buildQuickSelector onInput -->|calls| buildQuickSelector onChange -->|calls| buildQuickSelector captureUnrecordedFormFields -->|calls| buildQuickSelector processMutations -->|calls| buildQuickSelector style buildQuickSelector fill:#dbeafe,stroke:#2563eb,stroke-width:2px click buildQuickSelector "077a2e134af1a6be.html" click detectSubmitActions "b33db39bc3e0f928.html" click buildStep "6d1088fe63d8f4bc.html" click onInput "578e68a59cf9ed07.html" click onChange "63739279f8aaa1aa.html" click captureUnrecordedFormFields "5a9cd35f60b34b67.html" click processMutations "1402c8dfccd81bea.html"