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(compiler-ssr): handle newlines at the beginning of textarea content #11874

Closed
wants to merge 3 commits into from

Conversation

linzhe141
Copy link
Contributor

@linzhe141 linzhe141 commented Sep 10, 2024

close #11873

I've learned from React's implementation and applied it here.

image

Copy link

github-actions bot commented Sep 10, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 37.7 kB 34 kB
vue.global.prod.js 159 kB 57.6 kB 51.3 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.8 kB 18.8 kB 17.2 kB
createApp 55.3 kB 21.2 kB 19.4 kB
createSSRApp 59.3 kB 22.9 kB 20.9 kB
defineCustomElement 60 kB 22.8 kB 20.7 kB
overall 69 kB 26.3 kB 23.9 kB

Copy link

pkg-pr-new bot commented Sep 10, 2024

Open in Stackblitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/runtime-core

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

@vue/reactivity

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

@vue/runtime-dom

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

@vue/shared

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

@vue/server-renderer

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

@vue/compat

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

vue

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

commit: 67d0986

@edison1105 edison1105 added need test The PR has missing test cases. scope: ssr labels Sep 10, 2024
@edison1105 edison1105 added ready to merge The PR is ready to be merged. and removed need test The PR has missing test cases. labels Sep 10, 2024
@edison1105
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Sep 10, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure failure
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros failure success
vuetify success success
vueuse success success
vue-simple-compiler success success

@yyx990803 yyx990803 closed this in a5f3c2e Sep 13, 2024
@yyx990803
Copy link
Member

Thanks for looking into this. This PR only affects <textarea> with dynamic binding so it is incomplete. The test happens to pass because when <textarea> is at template root it also gets attribute fallthrough which causes it to go into the branch this PR modifies.

There are a few different aspects of this issue:

  1. This behavior (parser eating the first newline) applies to <pre> too.

  2. This behavior should be respected in the Vue parser as well - for example, currently the leading newline in <textarea> will result in different render result from native HTML. We previously had a special condition for <pre> in the parser, but not for <textarea>. This is addressed in 3c4bf76.

  3. However, only respecting it in the parser or compiler-ssr is not enough to completely fix <textarea> triggers hydration error on whitespace #11873 because (1) there can be more than one newlines at the start of the element and (2) there can be manual render functions. The only complete fix is to detect this at runtime during hydration, as in a5f3c2e.

@linzhe141 linzhe141 deleted the fix-ssr-textarea branch September 13, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

<textarea> triggers hydration error on whitespace
4 participants