mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): fetch non-server rendered islands when hydrating (#25613)
This commit is contained in:
parent
8705aed8b4
commit
7dd0225007
@ -224,9 +224,9 @@ export default defineComponent({
|
|||||||
watch(props, debounce(() => fetchComponent(), 100), { deep: true })
|
watch(props, debounce(() => fetchComponent(), 100), { deep: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.client && !nuxtApp.isHydrating && props.lazy) {
|
if (import.meta.client && !instance.vnode.el && props.lazy) {
|
||||||
fetchComponent()
|
fetchComponent()
|
||||||
} else if (import.meta.server || !nuxtApp.isHydrating || !nuxtApp.payload.serverRendered) {
|
} else if (import.meta.server || !instance.vnode.el || !nuxtApp.payload.serverRendered) {
|
||||||
await fetchComponent()
|
await fetchComponent()
|
||||||
} else if (selectiveClient && canLoadClientComponent.value) {
|
} else if (selectiveClient && canLoadClientComponent.value) {
|
||||||
await loadComponents(props.source, payloads.components)
|
await loadComponents(props.source, payloads.components)
|
||||||
|
@ -1530,6 +1530,9 @@ describe('server components/islands', () => {
|
|||||||
await page.locator('#show-island').click()
|
await page.locator('#show-island').click()
|
||||||
expect(await page.locator('#island-mounted-client-side').innerHTML()).toContain('Interactive testing slot post SSR')
|
expect(await page.locator('#island-mounted-client-side').innerHTML()).toContain('Interactive testing slot post SSR')
|
||||||
|
|
||||||
|
// test islands wrapped with client-only
|
||||||
|
expect(await page.locator('#wrapped-client-only').innerHTML()).toContain('Was router enabled')
|
||||||
|
|
||||||
if (!isWebpack) {
|
if (!isWebpack) {
|
||||||
// test client component interactivity
|
// test client component interactivity
|
||||||
expect(await page.locator('.interactive-component-wrapper').innerHTML()).toContain('Sugar Counter 12')
|
expect(await page.locator('.interactive-component-wrapper').innerHTML()).toContain('Sugar Counter 12')
|
||||||
|
4
test/fixtures/basic/pages/islands.vue
vendored
4
test/fixtures/basic/pages/islands.vue
vendored
@ -20,10 +20,14 @@ const count = ref(0)
|
|||||||
name="PureComponent"
|
name="PureComponent"
|
||||||
:props="islandProps"
|
:props="islandProps"
|
||||||
/>
|
/>
|
||||||
|
<div id="wrapped-client-only">
|
||||||
|
<ClientOnly>
|
||||||
<NuxtIsland
|
<NuxtIsland
|
||||||
name="PureComponent"
|
name="PureComponent"
|
||||||
:props="islandProps"
|
:props="islandProps"
|
||||||
/>
|
/>
|
||||||
|
</ClientOnly>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
id="increase-pure-component"
|
id="increase-pure-component"
|
||||||
|
Loading…
Reference in New Issue
Block a user