Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rendering HTML comments #301

Merged
merged 3 commits into from
Jun 9, 2023
Merged

Conversation

marvinhagemeister
Copy link
Member

@marvinhagemeister marvinhagemeister commented Jun 6, 2023

This PR adds support for rendering HTML comments via preact-render-to-string. Instead of adding a new vnode type this leverages Fragments. This has the benefit that branching cost is minimal as Fragments are the least frequently used components and they sorta represent "nothing" in terms of client code.

<Fragment UNSTABLE_comment="foobar" /> renders <!--foobar-->. When the prop is present, all other children are ignored.

This solves an issue with fresh which currently renders invalid HTML comments. Browsers happily parse over that, but it's annoying if you're testing with HTML validators on CI. See denoland/fresh#838

@changeset-bot
Copy link

changeset-bot bot commented Jun 6, 2023

🦋 Changeset detected

Latest commit: 8e0a6e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This is done via Fragments because they are the least common components.
That way the additional branching has minimal impact
@marvinhagemeister marvinhagemeister marked this pull request as ready for review June 7, 2023 09:47
@marvinhagemeister
Copy link
Member Author

Marked the name as unstable as proposed in yesterday's call.

@marvinhagemeister marvinhagemeister merged commit e68d93c into master Jun 9, 2023
@marvinhagemeister marvinhagemeister deleted the comments branch June 9, 2023 05:41
@github-actions github-actions bot mentioned this pull request Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants