Repository navigation
fix(compiler): nullish checkbox/radio value removes the attribute in non-hydratable builds (#4017) - #4021
Conversation
…non-hydratable builds (#4017) Both compilers inlined the #2957 text-field fallback (`el.value = v ?? ""`) for value/defaultValue on every input, so a client-only build never reached the #4009 runtime path and a checked checkbox with a nullish value submitted "" instead of "on". When an <input>'s static `type` is checkbox or radio (case-insensitive), or its type cannot be resolved at compile time (expression, prop:type, attr:type), a non-literal value/defaultValue now compiles to the existing `setProperty` runtime helper, which already tests the live type. Inputs with no type or another static type, and textareas, keep the inline `?? ""`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NcUAu8BQ6Xsf8XRBhr9V1w
🦋 Changeset detectedLatest commit: 6c62af6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size (brotli, eager entry chunk)
|
Generated by Claude Code |
Coverage Report for CI Build 38433179373Coverage remained the same at 77.429%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Merging this PR will regress 1 benchmark
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | memo + sync render effect only (reference) |
28.6 ms | 32.5 ms | -11.92% |
| ⚡ | createStore setter: delete + set one root key (#3044 overlay) |
2.1 ms | 1.8 ms | +16.44% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing claude/project-thread-w8qjvi-4017 (6c62af6) with next (be845cb)
Generated by Claude Code |
Generated by Claude Code |
Requested by Ryan · project thread
Summary
Fixes #4017 (follow-up to #4009).
Before: in non-hydratable client builds, both compilers inlined
el.value = v ?? ""for every input, so<input type="checkbox" value={v()} checked />submitted""whenv()was nullish, unlike hydratable builds and spreads.After: when an input may be a checkbox or radio, a dynamic
value/defaultValuecompiles tosetProperty(el, name, v), the same runtime path #4009 fixed, so a nullish value removes the attribute and the box submits"on". Text inputs, untyped inputs andtextareakeep the #2957?? ""clearing.How: both compilers use the same rule, without constant folding, so they can't diverge.
typeofcheckbox/radio(case-insensitive):setProperty.type, or any other static string: unchanged inline?? "".type(expression, identifier,prop:type,attr:type):setProperty, which checks the live type at runtime.<input type="checkbox" value={v()}/>el.value = v ?? ""setProperty(el, "value", v)<input type="radio" defaultValue={v()}/>el.defaultValue = v ?? ""setProperty(el, "defaultValue", v)<input type={kind()} value={v()}/>el.value = v ?? ""setProperty(el, "value", v)<input type="text" value={v()}/>,<input value={v()}/>,<textarea value={v()}/>?? ""Public API changes
None.
setPropertyis an existing runtime import compiled output already uses (hydratable builds, and<select value>since #3928).How did you test this change?
packages/compiler/__tests__/dom-nullish-input-value.test.js(jsdom): compiles with Babel and Oxc, hydratable on and off, and mirrors the fix(web): preserve default checkbox and radio submission values #4009 runtime test. 8 cases fail with the source changes reverted (both compilers, non-hydratable).template100–template107inattributeExpressions, updated viavitest -uandUPDATE_OXC_FIXTURES=1; parity diffs regenerated withUPDATE_PARITY=1(only line/numbering shifts, no new divergence).test:rust(all three feature configs),cargo fmt --check, clippy clean. Compiler vitest 6212 passed. Babel plugin 299 passed.@solidjs/webinput-nullish-value.spec.ts52/52, client 1389, hydrate 493.🤖 Generated with Claude Code
https://claude.ai/code/session_01NcUAu8BQ6Xsf8XRBhr9V1w
Generated by Claude Code