Skip to content

Commit

Permalink
Add support for rendering HTML comments
Browse files Browse the repository at this point in the history
This is done via Fragments because they are the least common components.
That way the additional branching has minimal impact
  • Loading branch information
marvinhagemeister committed Jun 6, 2023
1 parent 52be312 commit a5dc77c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
// Invoke rendering on Components
if (typeof type === 'function') {
if (type === Fragment) {
// Fragments are the least use components of core that's why
// branching here for comments has the least effect on perf.
if (props.comment) {
return '<!--' + encodeEntities(props.comment || '') + '-->';
}

rendered = props.children;
} else {
contextType = type.contextType;
Expand Down

0 comments on commit a5dc77c

Please sign in to comment.