mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): pass params to client-only slot (#6584)
This commit is contained in:
parent
94f76ea930
commit
c688e1898c
@ -44,10 +44,10 @@ export function createClientOnly (component) {
|
||||
.then((setupState) => {
|
||||
return typeof setupState !== 'function'
|
||||
? { ...setupState, mounted$ }
|
||||
: () => {
|
||||
: (...args) => {
|
||||
return mounted$.value
|
||||
// use Fragment to avoid oldChildren is null issue
|
||||
? h(Fragment, null, [h(setupState(props, ctx), ctx.attrs)])
|
||||
? h(Fragment, null, [h(setupState(...args), ctx.attrs)])
|
||||
: h('div', ctx.attrs)
|
||||
}
|
||||
})
|
||||
|
@ -130,6 +130,14 @@ describe('pages', () => {
|
||||
|
||||
await expectNoClientErrors('/another-parent')
|
||||
})
|
||||
|
||||
it('/client-only-components', async () => {
|
||||
const html = await $fetch('/client-only-components')
|
||||
expect(html).toContain('<div class="client-only-script" foo="bar">')
|
||||
expect(html).toContain('<div class="client-only-script-setup" foo="hello">')
|
||||
|
||||
await expectNoClientErrors('/client-only-components')
|
||||
})
|
||||
})
|
||||
|
||||
describe('head tags', () => {
|
||||
|
17
test/fixtures/basic/components/ClientOnlyScript.client.vue
vendored
Normal file
17
test/fixtures/basic/components/ClientOnlyScript.client.vue
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
<script lang="ts">
|
||||
export default defineNuxtComponent({
|
||||
name: 'ClientOnlyScript',
|
||||
props: {
|
||||
foo: {
|
||||
type: String
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div>client only script component {{ foo }}</div>
|
||||
<slot name="test" />
|
||||
</div>
|
||||
</template>
|
10
test/fixtures/basic/components/ClientOnlySetupScript.client.vue
vendored
Normal file
10
test/fixtures/basic/components/ClientOnlySetupScript.client.vue
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ foo: string }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div>client only script setup component {{ props.foo }}</div>
|
||||
<slot name="test" />
|
||||
</div>
|
||||
</template>
|
12
test/fixtures/basic/pages/client-only-components.vue
vendored
Normal file
12
test/fixtures/basic/pages/client-only-components.vue
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div>
|
||||
<ClientOnlyScript class="client-only-script" foo="bar" />
|
||||
<ClientOnlySetupScript class="client-only-script-setup" foo="hello">
|
||||
<template #test>
|
||||
<div class="slot-test">
|
||||
Hello
|
||||
</div>
|
||||
</template>
|
||||
</ClientOnlySetupScript>
|
||||
</div>
|
||||
</template>
|
Loading…
Reference in New Issue
Block a user