Skip to content

Commit

Permalink
Merge pull request #9 from reslear/patch-1
Browse files Browse the repository at this point in the history
feat!: render Fragment instead div wrapper
  • Loading branch information
niklasfjeldberg authored Feb 3, 2024
2 parents 4747ae5 + c40487b commit a6e0739
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
18 changes: 10 additions & 8 deletions lib/blocksRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'vue';
import { h, Fragment, Comment } from 'vue';

import { Block } from './block';

Expand Down Expand Up @@ -80,13 +80,15 @@ export const BlocksRenderer = (props: BlocksRendererProps) => {
Block({ content, componentsContext }),
);

if(componentsContext.missingBlockTypes.length)

Check failure on line 83 in lib/blocksRenderer.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Insert `·`
divs.unshift(h(Comment, `missingBlockTypes: ${componentsContext.missingBlockTypes}`))

Check failure on line 84 in lib/blocksRenderer.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Replace `h(Comment,·`missingBlockTypes:·${componentsContext.missingBlockTypes}`))` with `⏎······h(Comment,·`missingBlockTypes:·${componentsContext.missingBlockTypes}`),⏎····);`

if(componentsContext.missingModifierTypes.length)

Check failure on line 86 in lib/blocksRenderer.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Insert `·`
divs.unshift(h(Comment, `missingModifierTypes: ${componentsContext.missingModifierTypes}`))

Check failure on line 87 in lib/blocksRenderer.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Replace `h(Comment,·`missingModifierTypes:·${componentsContext.missingModifierTypes}`))` with `⏎······h(⏎········Comment,⏎········`missingModifierTypes:·${componentsContext.missingModifierTypes}`,⏎······),⏎····);`

return h(

Check failure on line 89 in lib/blocksRenderer.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Replace `⏎····Fragment,⏎····divs⏎··);⏎` with `Fragment,·divs);`
'div',
{
class: 'strapi-blocks-wrapper',
missingBlockTypes: componentsContext.missingBlockTypes,
missingModifierTypes: componentsContext.missingModifierTypes,
},
divs,
Fragment,
divs
);

};
9 changes: 7 additions & 2 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<div class="strapi-blocks-wrapper" missingblocktypes="nonExistingType1,text2,nonExistingType2" missingmodifiertypes="nonExistingModifier1,nonExistingModifier2">',
'missingModifierTypes: nonExistingModifier1,nonExistingModifier2"',
);
});
it('non existing block types', () => {
expect(blocks2.html()).toContain(
'missingBlockTypes: nonExistingType1,text2,nonExistingType2"',
);
});
});
Expand Down

0 comments on commit a6e0739

Please sign in to comment.