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

:slotted() style does not work in SSR when multi component slotted the same compoennt #6093

Closed
mmis1000 opened this issue Jun 10, 2022 · 1 comment · Fixed by #6100
Closed
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has PR A pull request has already been submitted to solve the issue scope: slots scope: ssr

Comments

@mmis1000
Copy link
Contributor

mmis1000 commented Jun 10, 2022

Vue version

3.2.36

Link to minimal reproduction

https://codesandbox.io/s/vue-ssr-slot-id-bug-4bjevz?file=/src/App.vue

Also made a sfc playground for bug reproduction

https://play.vuejs.org/#__SSR__eNq1U01PwzAM/StRLnwIrQduVYUEaIdxYAh27KVrvdEtS6rEHUPT/juO049NlHFASFVr+9nOs/uyl/dVNdrWIGOZIGwqlSHcpVqIpCi3bJA50Rps43iXEkXUglGPJlEoSqKjVonLbVkhWeWmMhYF54uFNRtxMQrVnsFFn+D7dzg5DQw7hgtYZLVCsfdH5oZqNGh0cQiI0P+msanaW4dU05NEDRd5I9HlRi/K5WjljKbpuTiVvl+pwE4rLI12qezapjJTynw8cQxtDc0RVPMO+XogvnI7H0vliwUHdgup7DDM7BIwwOO3Z9iR3YEbU9SKss+Ar+CMqj3HkPZQ64JoH+Ux2wlvtNTLmRvvELRrh/JEeTGcn0ra8OOZ0Xu6t6PbdqG0xe7vnerHshqmNXphsEOuUwa9bAIY9eixXMjlUCsashtVcH4nC/aCLijlmzL4jFNtNDS4MDgH/+FXJ4z+fPxUIEgjFRQcjT19hOLy+qrvr4yNxVzRKo86+UqvsI7i0G74ovywmRb7ZS9DQ/9xonmWr5fWkJZiYaEYmqq9j0NDzWtEo+9m4DCJGuefBundltrhC2wFp+s=

Steps to reproduce

App.vue

<template>
  <div>
    <Inner>
      <Item />
    </Inner>
  </div>
</template>
<script>
import Inner from './Inner.vue'
import Item from './Item.vue'
export default {
  components: {
    Inner,
    Item
  }
}
</script>

Outer.vue

<template>
  <div>
    <slot />
  </div>
</template>
<style scoped>
:slotted(*) {
  background: red
}
</style>

Inner.vue

<template>
  <Outer>
    <slot />
  </Outer>
</template>

<script>
import Outer from './Outer.vue'
export default {
  components: {
    Outer
  }
}
</script>

<style scoped>
:slotted(*) {
  color: blue
}
</style>

Item.vue

<template>
  <button>Test</button>
</template>

What is expected?

The button has red background and blue text in rendered HTML.

Because the button is slotted by both component

What is actually happening?

No Style is applied and there are warning in the server console

[@vue/server-renderer] Skipped rendering unsafe attribute name: data-v-9cfee1a6-s data-v-3fa8c6d2-s

System Info

System:
    OS: Linux 5.4 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 7.35 GB / 62.72 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v14.18.1/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
  npmPackages:
    vue: 3.2.36 => 3.2.36

Any additional comments?

It seems the @vue/server-renderer forgot the handle the situation that scopeId is a white-space separated list.
And try to use something like data-v-9cfee1a6-s data-v-3fa8c6d2-s as attribute name

if (slotScopeId) {
if (!hasCloned) attrs = { ...attrs }
attrs![slotScopeId.trim()] = ''
}

Probably the faulty line

@mmis1000 mmis1000 changed the title :slotted() style does not work in SSR when multi component slotted the same element :slotted() style does not work in SSR when multi component slotted the same compoennt Jun 12, 2022
@mmis1000
Copy link
Contributor Author

mmis1000 commented Oct 25, 2022

Is there anyone also encountered this issue? The issue and pull request is opened for several months and without comment at all.
This bug breaks my style so I need to patch it locally. But I would like this to be fixed in vue itself instead of lying in my project patchset forever.

@haoqunjiang haoqunjiang added scope: slots has PR A pull request has already been submitted to solve the issue 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Mar 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has PR A pull request has already been submitted to solve the issue scope: slots scope: ssr
Projects
None yet
3 participants