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(hydration): the component vnode's el should be updated when a mismatch occurs. #12255

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

linzhe141
Copy link
Contributor

close #12253

Copy link

github-actions bot commented Oct 25, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+32 B) 38 kB (+13 B) 34.2 kB (+13 B)
vue.global.prod.js 159 kB (+32 B) 57.9 kB (+14 B) 51.5 kB (+22 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.9 kB 18.3 kB 16.7 kB
createApp 55 kB 21.3 kB 19.4 kB
createSSRApp 59 kB (+37 B) 23 kB (+15 B) 20.9 kB
defineCustomElement 59.8 kB 22.8 kB 20.8 kB
overall 68.7 kB 26.3 kB 24 kB

Copy link

pkg-pr-new bot commented Oct 25, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12255

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12255

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12255

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12255

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12255

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12255

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12255

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12255

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12255

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12255

vue

pnpm add https://pkg.pr.new/vue@12255

commit: b238dde

@yangxiuxiu1115
Copy link
Contributor

Maybe just re-update the el after hydateNode
initialVNode.el = instance.subTree.el

hydrateNode!(
el as Node,
instance.subTree,
instance,
parentSuspense,
null,
)
if (__DEV__) {
endMeasure(instance, `hydrate`)
}

@linzhe141 linzhe141 marked this pull request as draft October 25, 2024 03:51
@linzhe141 linzhe141 marked this pull request as ready for review October 25, 2024 05:49
@@ -1328,6 +1328,10 @@ function baseCreateRenderer(
parentSuspense,
null,
)
// when data-allow-mismatch is set, the component vnode's el may be incorrect, so it should be updated
if (initialVNode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vnode.el needs to be updated only if a mismatch occurs.
So this is not the proper fix. The correct fix should be in the handleMismatch function.

@linzhe141 linzhe141 changed the title fix(ssr): handle the data-allow-mismatch component in ssr fix(ssr): the component vnode's el should be updated when data-allow-mismatch is used Oct 25, 2024
@edison1105 edison1105 changed the title fix(ssr): the component vnode's el should be updated when data-allow-mismatch is used fix(ssr): the component vnode's el should be updated when a mismatch occurs. Oct 25, 2024
@edison1105 edison1105 changed the title fix(ssr): the component vnode's el should be updated when a mismatch occurs. fix(hydration): the component vnode's el should be updated when a mismatch occurs. Oct 25, 2024
@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: ssr 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. scope: ssr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rendering a component after a hydration mismatch throws an error
3 participants