Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-otters-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-labs/ssr-client': patch
---

Avoid nullish logical assignment in hydrate-lit-html which some minification process would not handle correctly. Fixes hydration errors in Next.js production bundles.
7 changes: 6 additions & 1 deletion packages/labs/ssr-client/src/lib/hydrate-lit-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ export const hydrate = (
}
// Create a new ChildPart and push it onto the stack
currentChildPart = openChildPart(rootValue, marker, stack, options);
rootPart ??= currentChildPart;
// Using nullish logical assignment below can cause next.js's swc to move
// the `openChildPart()` call above behind the nullish check.
// See https://github.com/lit/lit/issues/4289
if (rootPart === undefined) {
rootPart = currentChildPart;
}
rootPartMarker ??= marker;
} else if (markerText.startsWith('lit-node')) {
// Create and hydrate attribute parts into the current ChildPart on the
Expand Down