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(compiler-dom): move ssr specific template warning to compiler-ssr (fix #12088) #12704

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

Conversation

aelgn
Copy link

@aelgn aelgn commented Jan 13, 2025

fix #12088
The original feature
PR #10734 introduced a template compiler warning for html hierarchy that is known to introduce modifications of the DOM by browsers. This is reported as incompatible with the Vue SSR implementation. Helping the user avoid this pitfall is a good quality of life feature.

The Problem
As discussed in issue #12088 the implementation of this compiler warning causes problems for non SSR users, whom are required to follow the stricter and optional HTML syntax as laid out by the imported "html validation" code from https://github.com/MananTank/validate-html-nesting

  • Non-SSR users with large code bases gets their console output overwhelmed with warnings that do not affect them. Hiding potentially useful output - rendering the console practically useless.
  • Wording in the message refers to valid HTML as non-compliant with the spec. Which is incorrect: https://html.spec.whatwg.org/#the-table-element

The proposed fix
This PR moves the html validation to compiler-ssr and rewords the warning. Thus, the compiler warning will propagate to the warning context that runs compiler-ssr ie. the server-renderer.

Note that the user will still get the runtime client side warning that there is a hydration mismatch, just like before:

[Vue warn]: Hydration node mismatch:
- rendered on server: #text "qwop" (text) 
- expected on client: table 
  at <App>

Given (the correct) HTML:

<table>
   <tr>
      qwop
   </tr>
</table>

Copy link

pkg-pr-new bot commented Jan 14, 2025

Open in Stackblitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@12704

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@12704

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@12704

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@12704

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@12704

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@12704

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@12704

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@12704

@vue/shared

npm i https://pkg.pr.new/@vue/shared@12704

vue

npm i https://pkg.pr.new/vue@12704

@vue/compat

npm i https://pkg.pr.new/@vue/compat@12704

commit: 972cab4

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 38 kB 34.2 kB
vue.global.prod.js 158 kB 57.8 kB 51.4 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.4 kB 18.2 kB 16.6 kB
createApp 54.3 kB 21.2 kB 19.3 kB
createSSRApp 58.5 kB 22.9 kB 20.9 kB
defineCustomElement 59.2 kB 22.8 kB 20.7 kB
overall 68.4 kB 26.3 kB 24 kB

@edison1105 edison1105 added scope: compiler ready for review This PR requires more reviews labels Jan 14, 2025
@edison1105
Copy link
Member

LGTM

@edison1105 edison1105 added the 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews scope: compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect vite warning regarding nesting tr directly in table element
3 participants