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

null is being removed when used as value in dangerouslySetInnerHTML html #346

Closed
lfre opened this issue Apr 2, 2024 · 1 comment · Fixed by #360
Closed

null is being removed when used as value in dangerouslySetInnerHTML html #346

lfre opened this issue Apr 2, 2024 · 1 comment · Fixed by #360

Comments

@lfre
Copy link

lfre commented Apr 2, 2024

Printing out null as the contents of an HTML text node through dangerouslySetInnerHTML activates the async renderer #333, and is removed from the output.

It used to be undefined but switched to null after this PR #339

E.g:

  1. Correctly prints as text
<p dangerouslySetInnerHTML={{ __html: undefined }} />
  1. Activates async renderer indirectly and is removed from the output.
<p dangerouslySetInnerHTML={{ __html: null }} />
@lfre lfre changed the title "null" is being removed when used as value in dangerouslySetInnerHTML html null is being removed when used as value in dangerouslySetInnerHTML html Apr 2, 2024
@marvinhagemeister
Copy link
Member

Makes me wonder if that is a bug overall that we accepted non-string values as the HTML string. We should do the same as in Preact itself and only allow string + number children and treat anything else as empty.

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 a pull request may close this issue.

2 participants