Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ssr): avoid rendering transition-group slot content as a fragment #9961

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: only remove the outer fragment
  • Loading branch information
edison1105 committed Jan 3, 2024
commit c5b95446bb6684dbf2875d39d4297fe2b63ba0a8
25 changes: 15 additions & 10 deletions packages/server-renderer/src/helpers/ssrRenderSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,22 @@ export function ssrRenderSlotInner(
fallbackRenderFn()
}
} else {
// #9933
// Although we handle Transition/TransitionGroup in the transform stage
// without rendering it as a fragment, the content passed into the slot
// may still be a fragment.
// Therefore, here we need to avoid rendering it as a fragment again.
if (
transition &&
slotBuffer[0] === '<!--[-->' &&
slotBuffer[slotBuffer.length - 1] === '<!--]-->'
) {
slotBuffer.shift()
slotBuffer.pop()
}

for (let i = 0; i < slotBuffer.length; i++) {
const buffer = slotBuffer[i]
// #9933
// Although we handle Transition/TransitionGroup in the transform stage
// without rendering it as a fragment, the content passed into the slot
// may still be a fragment.
// Therefore, here we need to avoid rendering it as a fragment again.
if (transition && (buffer === '<!--[-->' || buffer === '<!--]-->')) {
continue
}
push(buffer)
push(slotBuffer[i])
}
}
}
Expand Down