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

Allow empty string text nodes #23

Merged
merged 2 commits into from
Jun 29, 2022
Merged

Allow empty string text nodes #23

merged 2 commits into from
Jun 29, 2022

Conversation

loteoo
Copy link
Contributor

@loteoo loteoo commented Jun 10, 2022

Currently, if you try to render a node like this:

text('')

It will actually render undefined 🤔

It goes through this part of the code to get HTML escaped, however, because the || operator considers '' a falsy value, it goes for node.name instead, which does not exist on a VDOM node. The first line in this escapeHtml function converts this undefined value to string, which ends up being the string 'undefined'.

I think this is a bug?

Hope this helps!

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Currently, if you try to render a node like this:
```js
text('')
```
It will go through this part of the code to get HTML escaped, however, because the `||` operator considers `''` a falsy value, it goes for `node.name` instead, which does not exist on a VDOM node. The first line in this `escapeHtml` function converts this `undefined` value to string, which ends up being the string `'undefined'`.

I think this is a bug?

Hope this helps!
@frenzzy frenzzy merged commit 6470b74 into kriasoft:master Jun 29, 2022
@frenzzy
Copy link
Member

frenzzy commented Jun 29, 2022

Just released under v4.0.1 🎉 Thank you!

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