fix: capture client-state setter expressions in event scope
Fixes #5741.
ClientStateVar.set_value() derives a JavaScript parameter name from its value. A custom event argument such as _event?.clientX therefore produces invalid JavaScript; other property expressions can shadow the enclosing event and read the wrong value.
Capture an explicit value in a zero-argument closure instead. The enclosing event callback supplies its scope, and .set without an explicit value keeps accepting the trigger's argument. Setter imports and initialization hooks are retained.
Validation on main at 6c3713012522:
- 18 generated-callback execution cases: 14 fail on unchanged source and four controls pass; all pass after the fix. Covers optional chaining, dot/bracket access, nested fields and arithmetic through direct callbacks,
call_functionandrun_script. - All 164 affected unit tests pass on Linux; the same tests also passed on Windows before the base refresh.
- All 14 browser cases pass across development and production, including raw/typed event arguments, direct
.setbindings and the existing shared-state behavior. - All nine full pre-commit hooks pass, including Pyright, ty, lint, formatting and code generation.
Full Linux suite: 15,281 passed, 64 skipped, two backend-reload failures. The backend-refusal/recovery test also fails on a clean worktree at the same base. The reload-hold test fails in the full suite but passes in both unchanged and patched isolated controls. The changed client-state tests pass in the full suite. These backend tests and implementation are unchanged by this PR; related readiness work is already open in #7416.
Keeping this draft pending backend-gate guidance and approval of the fork workflows. No complete upstream or local full-suite pass is claimed.
All submissions
- Followed CONTRIBUTING.md and checked for an existing open PR for this fix.
- Bug fix with an explanation, regression coverage, locally run tests and a news fragment.