From a6d01cafbaeb16dbcae5ca3376ef9dddb44e1af2 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Tue, 14 May 2024 16:55:25 +0200 Subject: [PATCH 1/2] return whole content from slot default --- packages/x-components/src/components/no-element.ts | 4 ++-- .../src/composables/__tests__/use-no-element-render.spec.ts | 4 ++-- .../x-components/src/composables/use-no-element-render.ts | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/x-components/src/components/no-element.ts b/packages/x-components/src/components/no-element.ts index ba4daaebb3..ea90699032 100644 --- a/packages/x-components/src/components/no-element.ts +++ b/packages/x-components/src/components/no-element.ts @@ -8,7 +8,7 @@ import { useNoElementRender } from '../composables/use-no-element-render'; * @internal */ export const NoElement = defineComponent({ - render() { - return useNoElementRender(this.$slots); + setup(props, { slots }) { + return () => useNoElementRender(slots); } }); diff --git a/packages/x-components/src/composables/__tests__/use-no-element-render.spec.ts b/packages/x-components/src/composables/__tests__/use-no-element-render.spec.ts index 80c39124e7..412f18fdc1 100644 --- a/packages/x-components/src/composables/__tests__/use-no-element-render.spec.ts +++ b/packages/x-components/src/composables/__tests__/use-no-element-render.spec.ts @@ -11,8 +11,8 @@ const renderUseNoElementRender = ({ const wrapper = mount( component ?? (defineComponent({ - render() { - return useNoElementRender(this.$slots); + setup(props, { slots }) { + return () => useNoElementRender(slots); } }) as ComponentOptions), { diff --git a/packages/x-components/src/composables/use-no-element-render.ts b/packages/x-components/src/composables/use-no-element-render.ts index 3e2ebeac7d..04c418d3df 100644 --- a/packages/x-components/src/composables/use-no-element-render.ts +++ b/packages/x-components/src/composables/use-no-element-render.ts @@ -11,9 +11,8 @@ import { VNode } from 'vue/types/vnode'; */ export function useNoElementRender( slots: { [key: string]: VNode[] | undefined } | SetupContext['slots'] -): VNode { - const defaultSlotContent = - typeof slots.default === 'function' ? slots.default()?.[0] : slots.default?.[0]; +): VNode | VNode[] { + const defaultSlotContent = typeof slots.default === 'function' ? slots.default() : slots.default; return defaultSlotContent ?? h(); } From 372a7b6be4496ec12381053ea843b43542856cc7 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 15 May 2024 09:25:00 +0200 Subject: [PATCH 2/2] fix build --- packages/x-components/src/components/global-x-bus.vue | 7 +++---- .../x-modules/facets/components/preselected-filters.vue | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/x-components/src/components/global-x-bus.vue b/packages/x-components/src/components/global-x-bus.vue index c1ab69f55a..2e448faa4c 100644 --- a/packages/x-components/src/components/global-x-bus.vue +++ b/packages/x-components/src/components/global-x-bus.vue @@ -17,7 +17,7 @@ */ export default defineComponent({ name: 'GlobalXBus', - setup(_, { listeners }) { + setup(_, { listeners, slots }) { const xBus = useXBus(); /** @@ -46,9 +46,8 @@ onBeforeUnmount(() => { subscription.unsubscribe(); }); - }, - render() { - return useNoElementRender(this.$slots); + + return () => useNoElementRender(slots); } }); diff --git a/packages/x-components/src/x-modules/facets/components/preselected-filters.vue b/packages/x-components/src/x-modules/facets/components/preselected-filters.vue index a60fe97df7..d85d4c5a0f 100644 --- a/packages/x-components/src/x-modules/facets/components/preselected-filters.vue +++ b/packages/x-components/src/x-modules/facets/components/preselected-filters.vue @@ -28,7 +28,7 @@ default: () => [] } }, - setup(props) { + setup(props, { slots }) { const xBus = useXBus(); /** @@ -67,9 +67,8 @@ * computed prop changes. */ watch(preselectedFilters, emitPreselectedFilters, { immediate: true }); - }, - render() { - return useNoElementRender(this.$slots); + + return () => useNoElementRender(slots); } });