Skip to content

fix(jsx): honor defaultValue/defaultChecked on input and textarea [#2820]#2833

Merged
viniciusdacal merged 1 commit into
mainfrom
fix/textarea-default-value
Apr 19, 2026
Merged

fix(jsx): honor defaultValue/defaultChecked on input and textarea [#2820]#2833
viniciusdacal merged 1 commit into
mainfrom
fix/textarea-default-value

Conversation

@viniciusdacal
Copy link
Copy Markdown
Contributor

Summary

Closes #2820.

<textarea defaultValue="..."> and <input defaultValue="..."> were silently dropped — the React-style uncontrolled-initial-value props have no HTML content attribute, so the compiler's fallback to setAttribute("defaultValue", ...) was a no-op in the browser, and the SSR DOM shim never serialized the assigned IDL property.

Routes them through the existing IDL-property path the framework already uses for value / checked:

  • @vertz/native-compiler: is_idl_property now recognizes defaultValue (input, textarea) and defaultChecked (input). Boolean shorthand (<input defaultChecked />) emits __el0.defaultChecked = true. IDL emission stays deferred until after __exitChildren().
  • @vertz/ui JSX runtime: IDL_PROPS includes the new keys so the test-time runtime defers them after children too.
  • vtz SSR DOM shim: defaultValue setter writes the value attribute on <input> and replaces text content on <textarea>; defaultChecked toggles the checked attribute on <input>. No-op on other elements to preserve plain JS-property semantics.

Public API Changes

  • Additions: defaultValue on <input> / <textarea> and defaultChecked on <input> now behave like the React/HTML standard. No type changes — they were already accepted via the catch-all on HTMLAttributes.
  • Breaking: none.

Test plan

  • cargo test --all (1135 + 3469 + others all green; only the previously-ignored inspector_brk test stays ignored)
  • cargo clippy --all-targets -- -D warnings clean
  • cargo fmt --all -- --check clean
  • vtz test on packages/ui/src/jsx-runtime and packages/ui/src/dom (415 / 415 pass)
  • New unit tests added:
    • is_idl_property_default_value (compiler-core)
    • textarea_default_value_static_emits_idl_assignment, input_default_value_static_emits_idl_assignment, input_default_checked_boolean_shorthand_emits_idl_assignment (compiler-core)
    • test_textarea_default_value_serializes, test_input_default_value_serializes, test_input_default_checked_serializes, test_default_value_no_op_on_div (vtz dom_shim)
    • defaultValue / defaultChecked cases in jsx-idl-props.test.ts (@vertz/ui)

🤖 Generated with Claude Code

]

The React-style uncontrolled-initial-value props were silently dropped:

  <textarea defaultValue="Hello world" />  // rendered empty
  <input defaultValue="initial" />          // rendered empty
  <input type="checkbox" defaultChecked /> // rendered unchecked

Both have no HTML content attribute, so the compiler's fallback to
setAttribute("defaultValue", ...) was a no-op in the browser, and the
SSR DOM shim never serialized the assigned IDL property.

Route them through the existing IDL property path:

- native compiler: is_idl_property("input", "defaultValue"),
  is_idl_property("input", "defaultChecked"),
  is_idl_property("textarea", "defaultValue"). Boolean shorthand
  (<input defaultChecked />) emits .defaultChecked = true.
- @vertz/ui jsx-runtime IDL_PROPS: same set, deferred until after
  children are appended.
- vtz SSR DOM shim: defaultValue setter writes the value attribute on
  <input> and replaces text content on <textarea>; defaultChecked
  toggles the checked attribute on <input>. No-op on other elements
  to preserve plain JS-property semantics.

Closes #2820.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@viniciusdacal viniciusdacal merged commit 5223868 into main Apr 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jsx: defaultValue on <textarea> and <input> is silently ignored

1 participant