Repository navigation
fix(server-renderer): render cloneVNode attrs on vapor slot content (#16269) - #16272
Closed
zhengdaodeguL wants to merge 1 commit into
Closed
zhengdaodeguL wants to merge 1 commit into
zhengdaodeguL wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Member
|
closing in favor of #16340 |
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.
Fixes #16269.
A VDOM component that clones the first vnode of its default slot with extra attrs (
cloneVNode(slots.default()[0], { class: 'trigger', 'aria-expanded': 'false' })) loses those attrs in SSR when the slot comes from a<script setup vapor>parent: the server renders a bare<button>hello</button>, the client expects the extras, and hydration reports a class mismatch. After hydration the attrs stay missing until their value changes.Root cause: the server-side wrapper for slots from a Vapor component created a
VaporSlotvnode but did not initialize itsvs.props/vs.attrsmetadata the way the client interop wrapper does.cloneVNodetherefore kept the extra attrs only on the outer vnode props, where the Vapor SSR path ignores them.This PR:
render.ts), mirroring the client interop wrapper (vs.props = vnode.props, key-onlyvnode.props,vs.attrs = EMPTY_OBJ).vs.attrsthrough the Vapor outlet path asslotAttrs.ssrRenderSlot, whenslotAttrsis present, renders the slot to vnodes and merges the attrs onto the single root withcloneVNode. Ordinary slots keep the existing buffered SSR path, so client behavior and non-Vapor SSR output are unchanged.Test: added a case to
ssrVaporSlotRuntimes.spec.ts(a VDOM child renderscloneVNodeattrs on vapor slot content). Before the fix it renders<button>hello</button>; after,<button class="trigger" aria-expanded="false">hello</button>.Validation:
vp testonssrVaporSlotRuntimes.spec.ts,ssrSlot.spec.ts, andrender.spec.ts— 267 passed;vp run check,vp lint, andvp fmt --checkpass on the changed files.Closes #16269