ITADN
vuejs/core/Issues

Component VNode props named "style" are incorrectly normalized by normalizeStyle

#14923OpenJungzl 创建于 2026-06-05
J
Jungzlcommented
### Vue version 3.5.35 ### Link to minimal reproduction https://play.vuejs.org/#eNqFUk1v2zAM/SuELsmAzj5sJ8MNkBY9bIet2HarejASOlUnS4JEpxkM//dRVJO1WD9OEvn4qPdETmodQrUfUTWqTZtoAoHt3O5cK0paQUIaw0o7MwQfCS79EKCPfoBFVecgUxcneIKIPcyPFQXaeJcIEv2xCOcZX95oB1xqcY+2gcV6AfPZ89TF/6nLkrr9oF1bF6EsiwPCIdiOkCOAVgQ28hpbkJNd1Ay29ZNKdcb2WFlvdtV98o7dT5mv1YYbGIvxeyDDyrVqQJCMddb6h6+SoziiKBTOHW5+v5C/T4ec0+o6YsK4ZyknjLq4Qyrw1c9veOD7CRz8dszC3wB/YPJ2zBpL2cXotiz7SZ2o/SKDMW73K10dCF06mspCc2X5Z614WPnvXrP+T+6n6rPwtJv5F4878M76bLE3Dh8bL6WrcXcYDa2JYmqg72xiPTOPtyxMiD4kXpjCvM5RKzyZKSs7bkaiyPZgvrll+mrJDUoLb7F66KJbSqdKaO8sz2jl5Js1sP/Y+8g+DNew2PKuVqtpAknNc1tbU4i1MJ9v2PwXX+ghOQ== ### Steps to reproduce Comp.vue ```vue <script lang="ts" setup> defineOptions({ inheritAttrs: false }) const props = defineProps<{ style: { level: string }[] }>() console.warn(props.style) </script> <template> <ul> <li v-for="item in style">{{ item }}</li> </ul> </template> ``` App.vue ```vue <script lang="ts" setup> import Comp from './Comp.vue' import { ref } from 'vue' const style = ref([ { level: 'A' }, { level: 'B' }, { level: 'C' }, ]) </script> <template> <Comp :style="style" /> </template> ``` ### What is expected? `props.style` should be the original array `[{ level: 'A' }, { level: 'B' }, { level: 'C' }]`, since style is a declared component prop, not a CSS style attribute. ### What is actually happening? Vue applies `normalizeStyle()` to the style prop of all VNodes in `_createVNode`: https://github.com/vuejs/core/blob/9d92dbded20037a1142a08d554ea24969c35bb5c/packages/runtime-core/src/vnode.ts#L593-L608 The array `[{ level: 'A' }, { level: 'B' }, { level: 'C' }]` is merged into `{ level: 'C' }` (last element wins). The console also warns: Invalid prop: type check failed for prop "style". Expected Array, got Object. ### System Info ```shell ``` ### Any additional comments? _No response_
0 条评论