onInput function ✓ 100.0%

Last updated: 2026-03-05T11:49:57.418Z

Metrics

LOC: 44 Complexity: 15 Params: 1 Coverage: 100.0% (23/23 lines, 0x executed)

Signature

onInput(e: Event): : void

Architecture violations

View all

  • [warning] max-cyclomatic-complexity: 'onInput' has cyclomatic complexity 15 (max 10)

Source Code

function onInput(e: Event): void {
  const el = e.target;
  if (
    !(
      el instanceof HTMLInputElement ||
      el instanceof HTMLTextAreaElement ||
      el instanceof HTMLSelectElement
    )
  )
    return;
  if (!session || session.status !== "recording") return;
  if (isExtensionUI(el)) return;

  // Debounce rapid typing — only record the last value
  const lastStep = session.steps[session.steps.length - 1];
  if (
    lastStep?.type === "fill" &&
    lastStep.selector === buildQuickSelector(el) &&
    now() - lastStep.timestamp < 500
  ) {
    lastStep.value = el.value;
    lastStep.timestamp = now();
    onStepUpdatedCallback?.(lastStep, session.steps.length - 1);
    return;
  }

  if (el instanceof HTMLSelectElement) {
    addStep(buildStep("select", el, { value: el.value }));
    return;
  }

  if (el instanceof HTMLInputElement) {
    if (el.type === "checkbox") {
      addStep(buildStep(el.checked ? "check" : "uncheck", el));
      return;
    }
    if (el.type === "radio") {
      addStep(buildStep("check", el, { value: el.value }));
      return;
    }
  }

  addStep(buildStep("fill", el, { value: el.value }));
}

Dependencies (Outgoing)

graph LR onInput["onInput"] isExtensionUI["isExtensionUI"] buildQuickSelector["buildQuickSelector"] now["now"] addStep["addStep"] buildStep["buildStep"] onInput -->|calls| isExtensionUI onInput -->|calls| buildQuickSelector onInput -->|calls| now onInput -->|calls| addStep onInput -->|calls| buildStep style onInput fill:#dbeafe,stroke:#2563eb,stroke-width:2px click onInput "578e68a59cf9ed07.html" click isExtensionUI "d32bf4175ca1ff44.html" click buildQuickSelector "077a2e134af1a6be.html" click now "b0f01bcc017e0081.html" click addStep "012da91201f9487b.html" click buildStep "6d1088fe63d8f4bc.html"
TargetType
isExtensionUI calls
buildQuickSelector calls
now calls
addStep calls
buildStep calls

No incoming dependencies.