From fd671a27eaeefa10bb74885fbaa6e5866370b996 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 9 Feb 2024 20:33:35 +0000 Subject: [PATCH] fix(nuxt): don't check for layout/page with `` (#25714) --- packages/nuxt/src/app/components/client-only.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/components/client-only.ts b/packages/nuxt/src/app/components/client-only.ts index b74e050c30..a526347122 100644 --- a/packages/nuxt/src/app/components/client-only.ts +++ b/packages/nuxt/src/app/components/client-only.ts @@ -1,5 +1,6 @@ import { cloneVNode, createElementBlock, createStaticVNode, defineComponent, getCurrentInstance, h, onMounted, provide, ref } from 'vue' import type { ComponentInternalInstance, ComponentOptions, InjectionKey } from 'vue' +import { useNuxtApp } from '../nuxt' import { getFragmentHTML } from './utils' export const clientOnlySymbol: InjectionKey = Symbol.for('nuxt:client-only') @@ -12,6 +13,12 @@ export default defineComponent({ setup (_, { slots, attrs }) { const mounted = ref(false) onMounted(() => { mounted.value = true }) + // Bail out of checking for pages/layouts as they might be included under `` 🤷‍♂️ + if (import.meta.dev) { + const nuxtApp = useNuxtApp() + nuxtApp._isNuxtPageUsed = true + nuxtApp._isNuxtLayoutUsed = true + } provide(clientOnlySymbol, true) return (props: any) => { if (mounted.value) { return slots.default?.() } @@ -63,7 +70,7 @@ export function createClientOnly (component: T) { // remove existing directives during hydration const directives = extractDirectives(instance) // prevent attrs inheritance since a staticVNode is rendered before hydration - for(const key in attrs) { + for (const key in attrs) { delete instance.attrs[key] } const mounted$ = ref(false)