fix: warn instead of crash on invalid HTML nesting around islands#3762
Merged
Conversation
) When block-level elements (like <div>) are placed inside inline elements (like <p>), the browser reparents the island markers into different DOM nodes. Previously this caused a fatal DOMException during hydration. Now Fresh detects the mismatched markers and logs a descriptive error message, skipping the broken island instead of crashing the entire page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that placing a block-level island (<div>) inside a <p> logs an error instead of crashing, and the rest of the page remains functional. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
<div>) is placed inside an inline element (e.g.<p>) that wraps an island, the browser fixes the invalid nesting by splitting the parent, moving Fresh's comment markers into different DOM nodesDOMExceptionduring hydration, crashing all client-side JS on the pagestart.parentNode !== end.parentNodebefore callingcreateRootFragment, logs a descriptive error message explaining the invalid nesting, and skips the broken island instead of crashingExample of the error message:
Closes #2121
Test plan
<p><MyIsland /></p>where MyIsland returns<div>— should log error instead of crashing🤖 Generated with Claude Code