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
fix(nuxt): exclude data-v
attrs from server component props
#23095
Conversation
Run & review this pull request in StackBlitz Codeflow. |
data-v
attributes of cssLoader to NuxtIslanddata-v
attributes to NuxtIsland
data-v
attributes to NuxtIslanddata-v
attributes to NuxtIsland
@@ -7,10 +7,12 @@ export const createServerComponent = (name: string) => { | |||
inheritAttrs: false, | |||
props: { lazy: Boolean }, | |||
setup (props, { attrs, slots }) { | |||
// #23051 - remove data-v attributes | |||
const attrsWithoutVueDataAttr = computed(() => Object.entries(attrs).reduce<Record<string, string>>((acc, [key, value]) => key.startsWith('data-v-') ? acc : Object.assign(acc, { [key]: value }), {})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do this within the render function, and I think it would likely be simpler to do Object.fromEntries
+ Object.entries().filter
.
Apologies, but if it's fixed by not passing the data-v attribute, won't this break styles during SSG? I think that might be a bigger problem actually, since that means that scoped styles won't apply during SSG and if you want to style server components used inside your components with scoped styles you'll have to use I mean, this can break styles in already existing applications, no? |
data-v
attributes to NuxtIslanddata-v
attributes to NuxtIsland props
Oh the title of the PR may not be explicit enough. |
Thanks for the clarification! |
data-v
attributes to NuxtIsland propsdata-v
attrs from server component props
β¦s inside rendered component
π Linked issue
fix #23051
β Type of change
π Description
Hi π this PR resolves #23051 .
I'm not really a fan of having to make a computed + a reduce, but i didn't find another solution atm. Let's admit that server components are not going to be updated every milliseconds π .... If there's a better solution (like a config from vue), let me know.
This only affect
.server
components sinceNuxtIsland
directly useprops
props attrbute and ignore anydata-v
attributeπ Checklist