handleSelect function
Last updated: 2026-03-05T20:45:07.036Z
Metrics
LOC: 34
Complexity: 11
Params: 1
Signature
handleSelect(step: FlowStep): : StepResult
Architecture violations
- [warning] max-cyclomatic-complexity: 'handleSelect' has cyclomatic complexity 11 (max 10)
Source Code
function handleSelect(step: FlowStep): StepResult {
const el = requireElement(step);
ensureVisible(el);
if (!(el instanceof HTMLSelectElement)) {
return { status: "failed", error: "Select target is not a <select>" };
}
if (step.selectIndex != null) {
if (step.selectIndex >= 0 && step.selectIndex < el.options.length) {
el.selectedIndex = step.selectIndex;
} else {
return {
status: "failed",
error: `Select index ${step.selectIndex} out of range`,
};
}
} else if (step.selectText != null) {
const option = Array.from(el.options).find(
(o) => o.text === step.selectText || o.value === step.selectText,
);
if (option) {
el.value = option.value;
} else {
return {
status: "failed",
error: `Option "${step.selectText}" not found`,
};
}
}
el.dispatchEvent(new Event("change", { bubbles: true }));
return { status: "success" };
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| requireElement | calls |
| ensureVisible | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| executeStep | calls |