Draft
Conversation
Separate template tree (static structure) from render tree (dynamic state): - Rename `children` → `template_children` for static structure - Add `render_children()` method to return currently mounted fragments - Add `render_parent` property for anchor lookups in slot contexts - Change `slot_contents` → `slot_content: dict[str, list[Fragment]]` Fragment-specific changes: - ControlFlowFragment: `_active_child` tracks current branch - ListFragment: `_generated_fragments` separate from template - ComponentFragment: dual mode (usage site vs render wrapper) - SlotFragment: sets `_render_parent` on slot content during mount Compiler changes: - Slot content created without parent, then slot_name set, then registered - Ensures slot_name is read correctly during register_child() Hot reload changes: - Traverse ListFragment._generated_fragments - Handle ComponentFragment.rendered_fragment in element lookup All 253 tests pass.
- Add iter_all_children() method to Fragment base class and all subclasses - ListFragment yields template_children + _generated_fragments - ComponentFragment yields template_children + rendered_fragment + slot_content - DynamicFragment yields template_children + _active_fragment Simplify hot_reload.py using iter_all_children(): - _find_affected_recursive: reduced from 50+ lines to 15 lines - _collect_used_modules_recursive: reduced from 25+ lines to 10 lines - _find_root_element: now uses render_children() instead of manual checks - _collect_state_recursive/_restore_state_recursive: use iter_all_children() Removed unused DynamicFragment import from hot_reload.py.
Use render_children() to find fragment's position among siblings instead of manually checking each fragment type's child collection. Slot content still needs special handling since it's rendered by SlotFragment, not directly by the ComponentFragment that holds it. Removed ListFragment import (no longer needed).
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.
No description provided.