Skip to content

fix: emit hydration comments for bindings when state is missing#71

Merged
mohamedmansour merged 2 commits into
mainfrom
bug/empty-hydration-markers
Mar 6, 2026
Merged

fix: emit hydration comments for bindings when state is missing#71
mohamedmansour merged 2 commits into
mainfrom
bug/empty-hydration-markers

Conversation

@mohamedmansour

@mohamedmansour mohamedmansour commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Previously, process_signal and process_for_loop in webui-handler only signal value or collection was found in state. If the value was missing, the markers were silently skipped, leaving the client-side hydration framework unable to locate and bind to those DOM positions.

This was inconsistent with process_if, which always emits markers regardless of whether the condition references missing values.

The fix moves on_binding_start/on_binding_end calls outside the value resolution check in process_signal, and replaces the early return in process_for_loop with an empty Vec so markers are still written around zero iterations.

Previously, process_signal and process_for_loop in webui-handler only
signal value or collection was found in state. If the value was missing,
the markers were silently skipped, leaving the client-side hydration
framework unable to locate and bind to those DOM positions.

This was inconsistent with process_if, which always emits markers
regardless of whether the condition references missing values.

The fix moves on_binding_start/on_binding_end calls outside the value
resolution check in process_signal, and replaces the early return in
process_for_loop with an empty Vec so markers are still written around
zero iterations.
@mohamedmansour mohamedmansour requested review from a team, akroshg and radium-v March 5, 2026 23:48

#[test]
fn test_hydration_missing_signal_still_emits_markers() {
let mut fragments = HashMap::new();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since I am not yet developed skill to understand this test - would it be better if the test has big giant comment explaining on what it is doing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AI can figure out the test contents easily, but isn't the name good? testing if hydration emits markers for missing signals

akroshg
akroshg previously approved these changes Mar 6, 2026

@akroshg akroshg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Verify that hydration comment markers are emitted when a signal value
is an empty string or a for-loop collection is an empty array. These
complement the missing-state tests and ensure markers are present for
all empty-value edge cases, not just null/missing ones.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohamedmansour mohamedmansour merged commit fac8aec into main Mar 6, 2026
10 checks passed
@mohamedmansour mohamedmansour deleted the bug/empty-hydration-markers branch March 6, 2026 01:09
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.

2 participants