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

Support other data types on top of strings in CSS v-bind #7028

Closed
szymonlicau opened this issue Nov 4, 2022 · 2 comments
Closed

Support other data types on top of strings in CSS v-bind #7028

szymonlicau opened this issue Nov 4, 2022 · 2 comments

Comments

@szymonlicau
Copy link

szymonlicau commented Nov 4, 2022

Vue version

3.2.41

Link to minimal reproduction

https://stackblitz.com/edit/nuxt-starter-phmbfs?file=components/TestBinding1.vue

HTML rendered on SSR is missing the binding for values used in calc(...) or repeat(...) expressions. For anything else - the inlined style contains appropriate properties. This may lead to content jumping around or changing after hydration. For example in case of repeat - if we have a CSS grid which has a number of columns based on a prop.

Steps to reproduce

Try to refresh the preview window (also see the plain HTML response returned by the server); in this case the hydration is also visible because the flex/grid properties get applied after hydration making the content jump:

  • TestBinding1.vue - flex container missing the gap on initial load, and applying that after hydration.
  • TestBinding2.vue - CSS grid missing proper columns definition and changing that after hydration.

What is expected?

All inlined styles present for all of the v-bind bindings in the HTML returned by server during SSR.

What is actually happening?

Missing inline styles for some v-bind bindings in the HTML (those used within calc or repeat` expressions within CSS); they get added during hydration.

System Info

No response

Any additional comments?

HTML rendered on SSR is missing the binding for values used in calc(...) or repeat(...) expressions.
For anything else - the inlined style contains appropriate properties.

This may lead to content jumping around or changing after hydration.
For example in case of repeat - if we have a CSS grid which has a number of columns based on a prop.

Previously reported here at Nuxt's repository but turns out it's not strictly Nuxt related after further checking.

Also checked without Nuxt on a plain Vite & SSR setup - same issue present:
https://stackblitz.com/edit/github-ne553q?file=README.md

@szymonlicau
Copy link
Author

szymonlicau commented Nov 4, 2022

FYI, after some digging - it's actually not depending on the expressions, but the type of the property we bind in CSS - in essence anything other than a string... gets skipped when generating the inline styles in HTML 🤔

Reproduction example for this (hydration is disabled to easier see the results; just inspect the element):

https://stackblitz.com/edit/github-ne553q-cxzcsw?file=src/components/TestBinding.vue

@szymonlicau szymonlicau changed the title v-bind HTML output missing on SSR if used within CSS expressions v-bind HTML output missing in some caseson SSR Nov 4, 2022
@szymonlicau szymonlicau changed the title v-bind HTML output missing in some caseson SSR v-bind HTML output missing in some cases on SSR Nov 4, 2022
@posva posva changed the title v-bind HTML output missing in some cases on SSR Support other data types on top of strings in CSS v-bind Nov 4, 2022
@edison1105
Copy link
Member

edison1105 commented Nov 6, 2022

duplicate of nuxt/nuxt#14586

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants