FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix edge case with rendering children as number 0 by dburles · Pull Request #18 · developit/vhtml · GitHub

Fix edge case with rendering children as number 0 - #18

Open
dburles wants to merge 3 commits into
developit:masterfrom
dburles:master
Open

Fix edge case with rendering children as number 0#18
dburles wants to merge 3 commits into
developit:masterfrom
dburles:master

Conversation

dburles commented Mar 18, 2019

Copy link
Copy Markdown

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

Comment thread src/vhtml.js
while (stack.length) {
let child = stack.pop();
if (child) {
if (child !== undefined && child !== null) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL