Skip to content

Conversation

dburles
Copy link

@dburles dburles commented Mar 18, 2019

Passing in number 0 as a child would result in nothing being rendered. See test:

https://github.com/dburles/vhtml/blob/88278a1fb47f93edb40e974ab4eaf6923169f4a4/test/vhtml.js#L169-L178

while (stack.length) {
let child = stack.pop();
if (child) {
if (child !== undefined && child !== null) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would allow <div>{true}</div> to render <div>true</div>. Do we want that? The VDOM libs ignore booleans.

In any case, this statement can compress to:

Suggested change
if (child !== undefined && child !== null) {
if (child != null) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also allowed it before so we could leave as is or correct it, up to you. The shorter version while shorter is not explicit, it's better to always use the === and !== operators. Just my thoughts.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would concur with @dburles that being more explicit is often clearer. Also on the <div>{true}</div> debate mimicking the behaviour of React/Preact etc. seems intuitive.

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.

3 participants