fix: make hydration work correctly with FAST-HTML example#65
Merged
mohamedmansour merged 1 commit intomainfrom Mar 5, 2026
Merged
fix: make hydration work correctly with FAST-HTML example#65mohamedmansour merged 1 commit intomainfrom
mohamedmansour merged 1 commit intomainfrom
Conversation
Two issues prevented the todo-fast example from working after hydration: 1. Class field initializers overwrote hydration state RenderableFASTElement calls prepare() synchronously during super(). Esbuild compiles `@observable items: TodoItemData[] = []` as `this.items = []` in the subclass constructor AFTER super() returns, silently overwriting the 3 items that prepare() extracted from the SSR shadow DOM. Fixed by removing class field initializers from @observable properties set in prepare(). 2. ObserverMap deep proxies silently swallowed immutable-style updates With `observerMap: 'all'`, each array item is wrapped with deep observable proxies. When onToggleItem used .map() to create new plain objects, instanceResolverChanged triggered deepMerge which compared proxied getter values via deepEqual and concluded nothing changed, silently dropping the state update. Fixed by mutating items in-place (item.state = 'done') so the observable setter fires directly. Other fixes: - Move todo-item loop from light DOM into shadow DOM template and query via this.shadowRoot instead of this - Always assign this.items in prepare() to guarantee a default - Add return true to onAddKeydown so the event propagates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two issues prevented the todo-fast example from working after hydration:
RenderableFASTElement calls prepare() synchronously during super(). Esbuild compiles
@observable items: TodoItemData[] = []asthis.items = []in the subclass constructor AFTER super() returns, silently overwriting the 3 items that prepare() extracted from the SSR shadow DOM. Fixed by removing class field initializers from @observable properties set in prepare().With
observerMap: 'all', each array item is wrapped with deep observable proxies. When onToggleItem used .map() to create new plain objects, instanceResolverChanged triggered deepMerge which compared proxied getter values via deepEqual and concluded nothing changed, silently dropping the state update. Fixed by mutating items in-place (item.state = 'done') so the observable setter fires directly.Other fixes: