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)
| Target | Type |
|---|---|
| isExtensionUI | calls |
| captureUnrecordedFormFields | calls |
| now | calls |
| addStep | calls |
| buildStep | calls |
| persistSession | calls |
No incoming dependencies.