Skip to content

Commit

Permalink
Add support for rendering bigints
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Feb 13, 2021
1 parent c123310 commit 3965119
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export function diffChildren(
// If this newVNode is being reused (e.g. <div>{reuse}{reuse}</div>) in the same diff,
// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have
// it's own DOM & etc. pointers
else if (typeof childVNode == 'string' || typeof childVNode == 'number') {
else if (
typeof childVNode == 'string' ||
typeof childVNode == 'number' ||
typeof childVNode === 'bigint'
) {
childVNode = newParentVNode._children[i] = createVNode(
null,
childVNode,
Expand Down
10 changes: 10 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ describe('render()', () => {
expect(scratch.innerHTML).to.equal('42');
});

it('should render bigint as text content', () => {
// Skip in browsers not supporting big integers
if (typeof BigInt === 'undefined') {
return;
}

render(BigInt(4), scratch);
expect(scratch.innerHTML).to.equal('4');
});

it('should render strings as text content', () => {
render('Testing, huh! How is it going?', scratch);
expect(scratch.innerHTML).to.equal('Testing, huh! How is it going?');
Expand Down

0 comments on commit 3965119

Please sign in to comment.