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