Skip to content

fix: prevent duplicated structural views during hydration - #7668

Merged
janechu merged 3 commits into
mainfrom
users/radium-v/fix-duplicated-items-during-hydration
Jul 29, 2026
Merged

fix: prevent duplicated structural views during hydration#7668
janechu merged 3 commits into
mainfrom
users/radium-v/fix-duplicated-items-during-hydration

Conversation

@radium-v

Copy link
Copy Markdown
Collaborator

Pull Request

📖 Description

Prevent duplicate structural views during hydration when server-rendered content exists but the initial client binding has no template.

The content binding now removes unmatched SSR structural ranges before later updates compose their current view. A nested declarative fixture reproduces the original duplicated progress and action controls.

👩‍💻 Reviewer Notes

This intentionally fixes the mismatch in HTMLBindingDirective.updateContent() instead of restoring ancestor-before-child hydration waiting.

The previous waiting mechanism depended on legacy defer-hydration behavior and asynchronously delayed element connection. Restoring it would make hydration correctness depend on definition and connection order, reintroduce lifecycle coupling removed in FAST 3, and require handling ancestor registries, disconnection, and streaming cases globally.

In this failure, hydration discovers an SSR structural range while the child’s initial client binding evaluates to no template. Because that range has no corresponding $fastView, a later parent property update composes a new view beside the unclaimed SSR DOM. The fix reconciles that mismatch at the content binding that owns the range by removing the surplus SSR nodes. This mirrors repeat() hydration, which already removes extra server-rendered ranges.

The tradeoff is that mismatched SSR nodes are discarded rather than adopted. This is intentional because the client binding currently says no view should exist; if state arrives later, the normal reactive update creates the correct view once. This preserves FAST 3’s synchronous, order-independent connection model.

📑 Test Plan

  • FAST Element build passed.
  • Focused binding and hydration tests: 134 passed.
  • Nested declarative hydration fixture: 5 passed.
  • Standard Chromium suite: 1,468 passed.
  • Biome and Beachball checks passed.

✅ Checklist

General

  • I have included a change request file using $ npm run change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Agents

  • I have linked to an existing issue in this project that this change addresses
  • I have read the skills
  • I have read the DESIGN.md file(s) in packages relevent to my changes
  • I have updated the DESIGN.md file(s) in packages relevent to my changes

@radium-v radium-v changed the title Users/radium v/fix duplicated items during hydration fix: prevent duplicated structural views during hydration Jul 29, 2026
@janechu
janechu merged commit 582df18 into main Jul 29, 2026
15 checks passed
@janechu
janechu deleted the users/radium-v/fix-duplicated-items-during-hydration branch July 29, 2026 19:08
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