fix: warn instead of crash on invalid HTML nesting around islands (#3762)
## Summary - When a block-level element (e.g. `<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 nodes - Previously this caused a fatal `DOMException` during hydration, crashing all client-side JS on the page - Now Fresh detects that `start.parentNode !== end.parentNode` before calling `createRootFragment`, logs a descriptive error message explaining the invalid nesting, and skips the broken island instead of crashing Example of the error message: ``` Fresh hydration error: the island "BugIsland" has invalid HTML nesting. Its start and end markers were reparented by the browser into different DOM nodes. This is usually caused by placing a block-level element (like <div>) inside an inline element (like <p> or <span>). Check the HTML around this island for invalid nesting. ``` Closes #2121 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
07878fcce9
commit
af3f30dbaa
@@ -0,0 +1,3 @@
|
||||
export function BlockIsland() {
|
||||
return <div class="block-island">hydrated</div>;
|
||||
}
|
||||
Reference in New Issue
Block a user