Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix edge case with rendering children as number 0
  • Loading branch information
dburles committed Mar 18, 2019
commit 88278a1fb47f93edb40e974ab4eaf6923169f4a4
2 changes: 1 addition & 1 deletion src/vhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function h(name, attrs) {

while (stack.length) {
let child = stack.pop();
if (child) {
if (child !== undefined) {
if (child.pop) {
for (let i=child.length; i--; ) stack.push(child[i]);
}
Expand Down
11 changes: 11 additions & 0 deletions test/vhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,15 @@ describe('vhtml', () => {
'<div class="my-class" for="id"></div>'
);
});

it('should render a child of 0', () => {
function Child ({ children }) {
return <span>{children}</span>;
}
expect(
<div><Child>{0}</Child></div>
).to.equal(
'<div><span>0</span></div>'
);
});
});