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

dx(vnode): warn on render child nodes in self-closing tag #12137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yangxiuxiu1115
Copy link
Contributor

fix #12136

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB 38.1 kB 34.2 kB
vue.global.prod.js 160 kB 58 kB 51.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49.1 kB 18.9 kB 17.3 kB
createApp 55.7 kB 21.4 kB 19.6 kB
createSSRApp 59.7 kB 23.1 kB 21 kB
defineCustomElement 60.4 kB 23 kB 20.9 kB
overall 69.4 kB 26.5 kB 24.1 kB

Copy link

pkg-pr-new bot commented Oct 10, 2024

Open in Stackblitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 44a6b08

@edison1105
Copy link
Member

edison1105 commented Oct 10, 2024

I don't think this is a correct fix.

  • Firstly, rendering elements inside an <img> tag is unreasonable.
  • Secondly, <img><span>1</span></img>, the internal <span> will be rendered. But <component is="img"><span>1</span></component>, the internal <span> will not be rendered. see Playground

If we really want to solve this issue

  • the internal <span> should be rendered. When mounting an element, if it is a void tag, its children should be rendered as sibling nodes. Not sure if this is worth it.
  • or, gives a warning if the user tries to render nodes in the void tag

@yangxiuxiu1115
Copy link
Contributor Author

you're right, hydrate checks shouldn't be skipped no matter what.

@edison1105
Copy link
Member

@yangxiuxiu1115
The solution I recommend is to give warnings in the DEV. Both ssr and client, when render the child node to a void tag, give the user a warning.
Note, this only happens in <component is="VOID_TAG">child nodes</component>
Would you like to give it a try?

@yangxiuxiu1115
Copy link
Contributor Author

sure, I'd love to.

@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as draft October 10, 2024 11:14
@yangxiuxiu1115 yangxiuxiu1115 marked this pull request as ready for review October 10, 2024 12:32
@yangxiuxiu1115 yangxiuxiu1115 changed the title fix(hydration): avoid self-closing tag sub-element hydraye matches dx(vnode): warn on render child nodes in self-closing tag Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSR generated code causes hydration mismatch for a recursive component
2 participants