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

SSR/Hydration: Re-Render due to hydration mismatch creates inconsistent DOM - textContent updated correctly, class attr isn't. #5063

Closed
loyep opened this issue Dec 6, 2021 · 5 comments · Fixed by #5953
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: ssr

Comments

@loyep
Copy link

loyep commented Dec 6, 2021

Version

3.2.23

Reproduction link

github.com

Steps to reproduce

  • step 1
yarn && yarn dev

What is expected?

Class and text values are the same.

What is actually happening?

img1

img2


<template>
  <div :class="color">
    {{ color }}
  </div>
</template>

<script lang="ts" setup>
import { computed } from "vue";

console.log(process.client);

const color = computed(() => {
  return process.client ? "black" : "red";
});
</script>

<style>
.red {
  color: red;
}
.black {
  color: black;
}
</style>
@loyep
Copy link
Author

loyep commented Dec 6, 2021

@posva

@loyep loyep changed the title use computed in a SSR project attributes and nodes is different Use computed in a SSR project attributes and nodes is different Dec 6, 2021
@LinusBorg
Copy link
Member

Seems we have a bug here when bailing out of hydration because of a mismatch - the text content was updated, but the class attribute wasn't.

@LinusBorg LinusBorg added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: ssr labels Dec 6, 2021
@LinusBorg
Copy link
Member

LinusBorg commented Dec 6, 2021

@loyep Even though yes, this is a bug - your usage of a computed here is wrong, too.

Looking at the console, you can see that it causes a hydration mismatch.

@LinusBorg LinusBorg removed the 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. label Dec 6, 2021
@LinusBorg LinusBorg changed the title Use computed in a SSR project attributes and nodes is different SSR/Hydration: Re-Render due to hydration mismatch creates inconsistent DOM - textContent updated correctly, class attr isn't. Dec 6, 2021
@loyep
Copy link
Author

loyep commented Dec 6, 2021

Yes, I know. Only in this way can we reproduce this problem quickly.

@loyep
Copy link
Author

loyep commented Dec 6, 2021

LinusBorg

Not only class, but also style attributes

@yyx990803 yyx990803 added the 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. label May 19, 2022
yyx990803 added a commit that referenced this issue May 19, 2022
- Include the actual element in the warning message
- Also warn class/style/attribute mismatches

Note: class/style/attribute mismatches are check-only and will not be
rectified.

close #5063
@yyx990803 yyx990803 removed the 🐞 bug Something isn't working label May 19, 2022
wmfgerrit pushed a commit to wikimedia/wikibase-termbox that referenced this issue Oct 18, 2022
Currently broken in Vue, due to vuejs/core#5063

Bug: T318137
Change-Id: I8a12a78bf62cccf4e9d900e09d9b49f6f124f893
yyx990803 added a commit that referenced this issue Dec 8, 2023
- Include the actual element in the warning message
- Also warn class/style/attribute mismatches

Note: class/style/attribute mismatches are check-only and will not be
rectified.

close #5063
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: ssr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants