fix(nuxt): apply scoped styles to islands (#23386)

This commit is contained in:
Arsen Goian 2023-09-28 10:36:13 +03:00 committed by GitHub
parent 9da77db358
commit 17e6c1f7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -50,7 +50,8 @@ export default defineComponent({
const error = ref<unknown>(null)
const config = useRuntimeConfig()
const nuxtApp = useNuxtApp()
const hashId = computed(() => hash([props.name, props.props, props.context, props.source]))
const filteredProps = computed(() => props.props ? Object.fromEntries(Object.entries(props.props).filter(([key]) => !key.startsWith('data-v-'))) : {})
const hashId = computed(() => hash([props.name, filteredProps.value, props.context, props.source]))
const instance = getCurrentInstance()!
const event = useRequestEvent()
// TODO: remove use of `$fetch.raw` when nitro 503 issues on windows dev server are resolved

View File

@ -11,8 +11,7 @@ export const createServerComponent = (name: string) => {
return h(NuxtIsland, {
name,
lazy: props.lazy,
// #23051 - remove data-v attributes
props: Object.fromEntries(Object.entries(attrs).filter(([key]) => !key.startsWith('data-v-')))
props: attrs
}, slots)
}
}

View File

@ -31,9 +31,9 @@ describe('runtime server component', () => {
expect(h).toHaveBeenCalledOnce()
if (!vi.mocked(h).mock.lastCall) { throw new Error('no last call') }
expect(vi.mocked(h).mock.lastCall![1]?.props).toBeTypeOf('object')
expect(Object.keys(vi.mocked(h).mock.lastCall![1]?.props)).not.toContain('data-v-123')
expect(vi.mocked(h).mock.lastCall![1]?.props).toMatchInlineSnapshot(`
{
"data-v-123": "",
"test": 1,
}
`)