From c40487ba6a80bb93e8dba45a5346df33d7d99c77 Mon Sep 17 00:00:00 2001 From: reslear Date: Tue, 30 Jan 2024 04:19:31 +0100 Subject: [PATCH] feat!: render Fragment insead div wrapper --- lib/blocksRenderer.ts | 18 ++++++++++-------- test/basic.test.ts | 9 +++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/blocksRenderer.ts b/lib/blocksRenderer.ts index 49d2513..343bb2a 100644 --- a/lib/blocksRenderer.ts +++ b/lib/blocksRenderer.ts @@ -1,4 +1,4 @@ -import { h } from 'vue'; +import { h, Fragment, Comment } from 'vue'; import { Block } from './block'; @@ -80,13 +80,15 @@ export const BlocksRenderer = (props: BlocksRendererProps) => { Block({ content, componentsContext }), ); + if(componentsContext.missingBlockTypes.length) + divs.unshift(h(Comment, `missingBlockTypes: ${componentsContext.missingBlockTypes}`)) + + if(componentsContext.missingModifierTypes.length) + divs.unshift(h(Comment, `missingModifierTypes: ${componentsContext.missingModifierTypes}`)) + return h( - 'div', - { - class: 'strapi-blocks-wrapper', - missingBlockTypes: componentsContext.missingBlockTypes, - missingModifierTypes: componentsContext.missingModifierTypes, - }, - divs, + Fragment, + divs ); + }; diff --git a/test/basic.test.ts b/test/basic.test.ts index b9efef8..8356329 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -90,9 +90,14 @@ const blocks2 = mount(StrapiBlocks, { }); describe('render blocks', () => { - it('non existing block types and modifiers', () => { + it('non existing block modifiers', () => { expect(blocks2.html()).toContain( - '
', + 'missingModifierTypes: nonExistingModifier1,nonExistingModifier2"', + ); + }); + it('non existing block types', () => { + expect(blocks2.html()).toContain( + 'missingBlockTypes: nonExistingType1,text2,nonExistingType2"', ); }); });