diff --git a/packages/astro/test/fixtures/preact-component/src/components/EmptyFrag.jsx b/packages/astro/test/fixtures/preact-component/src/components/EmptyFrag.jsx new file mode 100644 index 000000000..0a74552b5 --- /dev/null +++ b/packages/astro/test/fixtures/preact-component/src/components/EmptyFrag.jsx @@ -0,0 +1,5 @@ +import { h, Fragment } from 'preact'; + +export default function() { + return +} \ No newline at end of file diff --git a/packages/astro/test/fixtures/preact-component/src/pages/frag.astro b/packages/astro/test/fixtures/preact-component/src/pages/frag.astro new file mode 100644 index 000000000..a451768ce --- /dev/null +++ b/packages/astro/test/fixtures/preact-component/src/pages/frag.astro @@ -0,0 +1,10 @@ +--- +import FragComponent from '../components/EmptyFrag.jsx'; +--- + + + + Preact component returns fragment + + + \ No newline at end of file diff --git a/packages/astro/test/preact-component.test.js b/packages/astro/test/preact-component.test.js index 77e17e03c..31f206d7e 100644 --- a/packages/astro/test/preact-component.test.js +++ b/packages/astro/test/preact-component.test.js @@ -32,4 +32,12 @@ PreactComponent('Can use hooks', async ({ runtime }) => { assert.equal($('#world').length, 1); }); +PreactComponent('Can export a Fragment', async ({ runtime }) => { + const result = await runtime.load('/frag'); + if (result.error) throw new Error(result.error); + + const $ = doc(result.contents); + assert.equal($('body').children().length, 0, 'nothing rendered but it didn\'t throw.'); +}); + PreactComponent.run(); diff --git a/packages/renderers/renderer-preact/server.js b/packages/renderers/renderer-preact/server.js index 8465dbe69..ac8661a49 100644 --- a/packages/renderers/renderer-preact/server.js +++ b/packages/renderers/renderer-preact/server.js @@ -10,7 +10,7 @@ function check(Component, props, children) { } const { html } = renderToStaticMarkup(Component, props, children); - return Boolean(html); + return typeof html === 'string'; } function renderToStaticMarkup(Component, props, children) {