Skip to content

Commit f99902d

Browse files
Merge branch 'master' into karma-stack-traces
2 parents 5056f1b + dcdc32a commit f99902d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/diff/children.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ export function diffChildren(
5353
// If this newVNode is being reused (e.g. <div>{reuse}{reuse}</div>) in the same diff,
5454
// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have
5555
// it's own DOM & etc. pointers
56-
else if (typeof childVNode == 'string' || typeof childVNode == 'number') {
56+
else if (
57+
typeof childVNode == 'string' ||
58+
typeof childVNode == 'number' ||
59+
// eslint-disable-next-line valid-typeof
60+
typeof childVNode == 'bigint'
61+
) {
5762
childVNode = newParentVNode._children[i] = createVNode(
5863
null,
5964
childVNode,

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ declare namespace preact {
4848
| object
4949
| string
5050
| number
51+
| bigint
5152
| boolean
5253
| null
5354
| undefined;

test/browser/render.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,17 @@ describe('render()', () => {
256256
expect(scratch.innerHTML).to.equal('42');
257257
});
258258

259+
it('should render bigint as text content', () => {
260+
// Skip in browsers not supporting big integers
261+
if (typeof BigInt === 'undefined') {
262+
return;
263+
}
264+
265+
// eslint-disable-next-line no-undef, new-cap
266+
render(BigInt(4), scratch);
267+
expect(scratch.innerHTML).to.equal('4');
268+
});
269+
259270
it('should render strings as text content', () => {
260271
render('Testing, huh! How is it going?', scratch);
261272
expect(scratch.innerHTML).to.equal('Testing, huh! How is it going?');

0 commit comments

Comments
 (0)