mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
fix(nuxt): ensure we only increment hydrating count once (#22200)
This commit is contained in:
parent
f6b64f6a65
commit
449a01526a
@ -33,8 +33,9 @@ export default defineComponent({
|
||||
const layoutRef = ref()
|
||||
context.expose({ layoutRef })
|
||||
|
||||
const done = nuxtApp.deferHydration()
|
||||
|
||||
return () => {
|
||||
const done = nuxtApp.deferHydration()
|
||||
const hasLayout = layout.value && layout.value in layouts
|
||||
if (process.dev && layout.value && !hasLayout && layout.value !== 'default') {
|
||||
console.warn(`Invalid layout \`${layout.value}\` selected.`)
|
||||
|
@ -46,6 +46,8 @@ export default defineComponent({
|
||||
const _layoutMeta = inject(LayoutMetaSymbol, null)
|
||||
let vnode: VNode
|
||||
|
||||
const done = nuxtApp.deferHydration()
|
||||
|
||||
return () => {
|
||||
return h(RouterView, { name: props.name, route: props.route, ...attrs }, {
|
||||
default: (routeProps: RouterViewSlotProps) => {
|
||||
@ -76,7 +78,6 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
const key = generateRouteKey(routeProps, props.pageKey)
|
||||
const done = nuxtApp.deferHydration()
|
||||
|
||||
const hasTransition = !!(props.transition ?? routeProps.route.meta.pageTransition ?? defaultPageTransition)
|
||||
const transitionProps = hasTransition && _mergeTransitionProps([
|
||||
|
@ -1034,6 +1034,16 @@ describe('deferred app suspense resolve', () => {
|
||||
it('should wait for all suspense instance on initial hydration', async () => {
|
||||
await behaviour('/internal-layout/async-parent/child')
|
||||
})
|
||||
it('should fully hydrate even if there is a redirection on a page with `ssr: false`', async () => {
|
||||
const page = await createPage('/hydration/spa-redirection/start')
|
||||
await page.waitForLoadState('networkidle')
|
||||
|
||||
// Wait for all pending micro ticks to be cleared in case hydration hasn't finished yet.
|
||||
await page.evaluate(() => new Promise(resolve => setTimeout(resolve, 10)))
|
||||
|
||||
const html = await page.getByRole('document').innerHTML()
|
||||
expect(html).toContain('fully hydrated and ready to go')
|
||||
})
|
||||
})
|
||||
|
||||
describe('nested suspense', () => {
|
||||
|
1
test/fixtures/basic/nuxt.config.ts
vendored
1
test/fixtures/basic/nuxt.config.ts
vendored
@ -48,6 +48,7 @@ export default defineNuxtConfig({
|
||||
},
|
||||
routeRules: {
|
||||
'/route-rules/spa': { ssr: false },
|
||||
'/hydration/spa-redirection/**': { ssr: false },
|
||||
'/no-scripts': { experimentalNoScripts: true }
|
||||
},
|
||||
output: { dir: process.env.NITRO_OUTPUT_DIR },
|
||||
|
12
test/fixtures/basic/pages/hydration/spa-redirection/end.vue
vendored
Normal file
12
test/fixtures/basic/pages/hydration/spa-redirection/end.vue
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
const ready = ref('not yet hydrated')
|
||||
onNuxtReady(() => {
|
||||
ready.value = 'fully hydrated and ready to go'
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
{{ ready }}
|
||||
</div>
|
||||
</template>
|
11
test/fixtures/basic/pages/hydration/spa-redirection/start.vue
vendored
Normal file
11
test/fixtures/basic/pages/hydration/spa-redirection/start.vue
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
middleware: () => '/hydration/spa-redirection/end'
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
Tests whether hydration is properly resolved when loading
|
||||
</div>
|
||||
</template>
|
Loading…
Reference in New Issue
Block a user