Skip to content

fix(ssr): translate initial_value/checked/selected to HTML equivalents#5493

Open
costajohnt wants to merge 2 commits into
DioxusLabs:mainfrom
costajohnt:fix/ssr-initial-value-attribute
Open

fix(ssr): translate initial_value/checked/selected to HTML equivalents#5493
costajohnt wants to merge 2 commits into
DioxusLabs:mainfrom
costajohnt:fix/ssr-initial-value-attribute

Conversation

@costajohnt
Copy link
Copy Markdown
Contributor

Summary

  • Add ssr_attr_name() translation for virtual attributes (initial_value, initial_checked, initial_selected) to their HTML equivalents (value, checked, selected)
  • Apply translation in both static (cache.rs) and dynamic (renderer.rs) SSR paths

Why

The SSR renderer writes virtual attributes like initial_value literally into the HTML output (producing <input initial_value="hello">) instead of translating them to standard HTML attributes (<input value="hello">). The client-side interpreter (set_attribute.ts) already handles this mapping correctly, but the SSR path was missing it.

Verification

  • 4 new tests covering initial_value, initial_checked, initial_selected (static + dynamic)
  • All 21 SSR tests pass (4 new + 17 existing)
  • cargo check -p dioxus-ssr clean

Fixes #5491

@costajohnt costajohnt requested a review from a team as a code owner April 16, 2026 01:13
}
}

let mut dom = VirtualDom::new(app);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extrapolate the function to segment to call the var_func after instantiating

The SSR renderer wrote virtual attributes like `initial_value`
literally into the HTML output instead of translating them to
their HTML equivalents (`value`, `checked`, `selected`).

Add an `ssr_attr_name` translation function that maps these
Dioxus-specific props to standard HTML attributes, matching
what the client-side interpreter already does in set_attribute.ts.

Fixes DioxusLabs#5491
Collapse short assert_eq to single line per rustfmt, and remove
needless borrows flagged by clippy::needless_borrow.
@costajohnt costajohnt force-pushed the fix/ssr-initial-value-attribute branch from 9d0741c to 3053e01 Compare April 24, 2026 16:13
@costajohnt
Copy link
Copy Markdown
Contributor Author

Just a friendly ping on this one. CI is green and the change should be ready for a maintainer to take a look when there's bandwidth.

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.

initial_value sets initial_value attribute

2 participants