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

scoped style 在多节点情况下样式应用失败 #11978

Closed
guaijie opened this issue Sep 19, 2024 · 2 comments
Closed

scoped style 在多节点情况下样式应用失败 #11978

guaijie opened this issue Sep 19, 2024 · 2 comments

Comments

@guaijie
Copy link
Contributor

guaijie commented Sep 19, 2024

Vue version

3.5.3

Link to minimal reproduction

https://play.vuejs.org/#__PROD__eNp9Uk1v1DAQ/SuDL5uVIu+hcFmyKxWoBBwAUSQullCUTLIujm3ZzrIoyn/v2G6226rqbWbem+83sWtr+XFEtmWVb5y0ATyG0e6FloM1LsAEDjuYoXNmgBVRV2foEw7mIc430YmVCBa6MdoHGHwPu5herD6jUgZ+G6faN6u10NUmd6M+5AQcrKoDkgdQpbKNqr3fCdaSI9h+mlK1ea5SIyJWm4usyof/CsE3xmJLPo9pMMVyjVHGbWmK9r3Qc+ocuXtWskB83cme33mj6QKJL1hjBisVuu82SNpDsG2uFLGa1vj3NcWCG7Fc4s0Bm78vxO/8KcYE++HQozuiYGcs1K7HkOGb2294IvsMDqYdFbFfAX+iN2qMM2bah1G3NPYFL037JT1L6v6XvzkF1H5ZKg4amXPiC0bP+/jK6o/jXvG3KY/uSVdcHv9cQqBq3dMHA5W5lNPo8ToE58to3SoTyGqxkxofupZwWPSWhhKMPveEUaShpD6gkyEV20JXK0/rzGsiZ/nVESABLg2LR8jHthlKEyRoAZP+dlCsYbeHQ0EalEc6Ko3OOc9F5zKXiGkXUn5JyJtsU41kPpGt0HS/P0d08Sd0Pzosv3rH5ns9sTW4

Steps to reproduce

App.vue

<script setup>
import { ref } from 'vue'
import Demo from './Demo.vue'

const msg = ref('Hello World!')
</script>

<template>
  <Demo class="demo">{{ msg }}</Demo>
</template>
<style scoped>
.demo {
  color: red;
}
</style>

Demo.vue

<script setup lang="ts">
import { useAttrs, useSlots, defineOptions, h } from "vue";
defineOptions({
  inheritAttrs: false
});
const attrs = useAttrs();
const slots = useSlots();

const Demo = () => h("div", { ...attrs }, slots);
</script>
<template>
  <Demo />
  <div />
</template>

当 Demo 组件有多个节点时,添加有 scoped 属性的 style 中的样式应用失败,当删除 <div /> 节点时,样式应用成功

What is expected?

无论是单节点组件还是多节点组件,添加有 scoped 属性的 style 中的样式都应该应用成功

What is actually happening?

当是多节点组件时,添加有 scoped 属性的 style 中的样式应用失败

System Info

No response

Any additional comments?

No response

@guaijie guaijie changed the title scoped style 在多节点情况下应用失败 scoped style 在多节点情况下样式应用失败 Sep 19, 2024
@linzhe141
Copy link
Contributor

https://cn.vuejs.org/api/sfc-css-features.html#child-component-root-elements

根据文档,如果子组件存在根节点,那么根节点才会加父组件的的scopedId,现在是一个fragment,我觉得这种应该是正常行为

image

@edison1105
Copy link
Member

@edison1105 edison1105 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants