diff --git a/.changeset/neat-books-remain.md b/.changeset/neat-books-remain.md new file mode 100644 index 00000000..267db823 --- /dev/null +++ b/.changeset/neat-books-remain.md @@ -0,0 +1,5 @@ +--- +'preact-render-to-string': minor +--- + +Add support for `dangerouslySetInnerHTML` on Fragments. This allows you to insert unsafe raw HTML content without a wrapping container element. diff --git a/src/index.js b/src/index.js index f1bf5b93..090c9dd6 100644 --- a/src/index.js +++ b/src/index.js @@ -346,6 +346,9 @@ function _renderToString( // Fragments are the least used components of core that's why // branching here for comments has the least effect on perf. return ''; + } else if (props.dangerouslySetInnerHTML) { + let html = props.dangerouslySetInnerHTML.__html || ''; + return '' + html + ''; } rendered = props.children; diff --git a/test/render.test.jsx b/test/render.test.jsx index 19dea6b0..39ce2f72 100644 --- a/test/render.test.jsx +++ b/test/render.test.jsx @@ -857,6 +857,59 @@ describe('render', () => { ); expect(rendered).to.equal('
ignored
+