chore(morph): reinforce morph mechanism#72
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe island runtime hardens DOM morphing with keyed slot reconciliation, focus and form-state preservation, transition guards, and identical-output fast paths. Regression tests, render documentation, and package version requirements are updated accordingly. ChangesMorph engine hardening
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant IslandRenderEffect
participant applyMorph
participant morphChildren
participant DOM
participant MountedSlot
IslandRenderEffect->>IslandRenderEffect: compare output with lastRendered
IslandRenderEffect->>MountedSlot: update props when output is identical
IslandRenderEffect->>applyMorph: reconcile changed output
applyMorph->>morphChildren: morph the wrapped host
morphChildren->>DOM: preserve focus, form state, and keyed nodes
morphChildren->>MountedSlot: retain, rehome, or replace slot hosts
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ilha/src/index.ts`:
- Around line 3562-3573: The list reconciliation logic around listShrunk and
teardownMountedSlot currently remounts every surviving positional slot whenever
the total slot count decreases. Track the actual positional divergence caused by
the removed slot(s), and tear down only p: slots at or after that affected
position; preserve earlier positional slots and their state, effects, DOM, and
focus.
- Around line 600-619: Update restoreFocusAfterMorph so document.activeElement
=== active does not return before restoring selection or contenteditable ranges.
Only skip the focus() call when the element is already active, while continuing
to apply the selection and range restoration logic for connected elements.
- Around line 525-533: Update the select-option state tracking around
syncAttributes and morphChildren to preserve each option’s pre-morph selected
state by option identity rather than array index. Compare each resulting option
against its corresponding original option identity, and only run the o.selected
reset loop when an option’s selected attribute state actually changed; keyed
reorders without attribute changes must preserve the user’s live selection.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c892942-86d5-4678-a938-3d75fc49a567
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (12)
apps/website/package.jsonapps/website/src/pages/(content)/guide/island/render.mdxpackages/ilha/package.jsonpackages/ilha/src/index.test.tspackages/ilha/src/index.tspackages/router/package.jsonpackages/router/src/inplace-update.test.tspackages/store/package.jsontemplates/elysia/package.jsontemplates/hono/package.jsontemplates/nitro/package.jsontemplates/vite/package.json
Summary by CodeRabbit
<select>live selection without clobbering user choice, including keyed option reorders.data-morph-preserveand added dev warnings for updates that may replace stateful elements (iframe/video/audio/canvas).data-morph-preserveexamples.