From 2cdaf8065cb1c9f2b3ec919565ec436352ca5b35 Mon Sep 17 00:00:00 2001 From: Julien Huang <63512348+huang-julien@users.noreply.github.com> Date: Tue, 2 Aug 2022 17:05:02 +0200 Subject: [PATCH] feat(nuxt): remove wrapper from client only components (#6165) Co-authored-by: Daniel Roe --- .../nuxt/src/app/components/client-only.mjs | 44 ++++++++++++++----- test/basic.test.ts | 3 ++ .../basic/components/ClientWrapped.client.vue | 17 +++++++ test/fixtures/basic/pages/index.vue | 6 +++ 4 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 test/fixtures/basic/components/ClientWrapped.client.vue diff --git a/packages/nuxt/src/app/components/client-only.mjs b/packages/nuxt/src/app/components/client-only.mjs index f6a679710c..cedbda6763 100644 --- a/packages/nuxt/src/app/components/client-only.mjs +++ b/packages/nuxt/src/app/components/client-only.mjs @@ -1,4 +1,4 @@ -import { ref, onMounted, defineComponent, createElementBlock, h } from 'vue' +import { ref, onMounted, defineComponent, createElementBlock, h, Fragment } from 'vue' export default defineComponent({ name: 'ClientOnly', @@ -19,18 +19,38 @@ export default defineComponent({ }) export function createClientOnly (component) { + const { setup, render: _render, template: _template } = component + if (_render) { + // override the component render (non + + diff --git a/test/fixtures/basic/pages/index.vue b/test/fixtures/basic/pages/index.vue index d9c54e2254..092ca160c3 100644 --- a/test/fixtures/basic/pages/index.vue +++ b/test/fixtures/basic/pages/index.vue @@ -16,6 +16,7 @@ + @@ -31,4 +32,9 @@ useHead({ const foo = useFoo() const bar = useBar() +const clientRef = ref() + +onMounted(() => { + clientRef.value.exposedFunc() +})