onSubmit function ✓ 100.0%

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

Metrics

LOC: 26 Complexity: 7 Params: 1 Coverage: 100.0% (5/5 lines, 0x executed)

Signature

onSubmit(e: Event): : void

Source Code

function onSubmit(e: Event): void {
  const form = e.target as HTMLFormElement;
  if (!session || session.status !== "recording") return;
  if (isExtensionUI(form)) return;

  // Snapshot all current field values into the recording (captures values that
  // were pre-filled, auto-filled, or set by Fill All and thus never triggered
  // an 'input' event).
  captureUnrecordedFormFields(form);

  const lastStep = session.steps[session.steps.length - 1];
  // Avoid duplicate if we already captured the submit button click
  if (lastStep?.type === "submit" && now() - lastStep.timestamp < 200) return;

  const action = form.getAttribute("action");
  addStep(
    buildStep("submit", form, {
      url: action ?? undefined,
      label: "Form submit",
    }),
  );

  // Persist the session to sessionStorage so it survives a traditional
  // (non-AJAX) form submit that causes a full page navigation.
  persistSession();
}

Dependencies (Outgoing)

graph LR onSubmit["onSubmit"] isExtensionUI["isExtensionUI"] captureUnrecordedFormFields["captureUnrecordedFormFields"] now["now"] addStep["addStep"] buildStep["buildStep"] persistSession["persistSession"] onSubmit -->|calls| isExtensionUI onSubmit -->|calls| captureUnrecordedFormFields onSubmit -->|calls| now onSubmit -->|calls| addStep onSubmit -->|calls| buildStep onSubmit -->|calls| persistSession style onSubmit fill:#dbeafe,stroke:#2563eb,stroke-width:2px click onSubmit "8be45aca6a1f4353.html" click isExtensionUI "d32bf4175ca1ff44.html" click captureUnrecordedFormFields "5a9cd35f60b34b67.html" click now "b0f01bcc017e0081.html" click addStep "012da91201f9487b.html" click buildStep "6d1088fe63d8f4bc.html" click persistSession "6165c1b3efca0f90.html"
TargetType
isExtensionUI calls
captureUnrecordedFormFields calls
now calls
addStep calls
buildStep calls
persistSession calls

No incoming dependencies.