Skip to content

Commit f9a7b6d

Browse files
committed
bigint-render-impl
1 parent cb5c675 commit f9a7b6d

File tree

10 files changed

+40
-15
lines changed

10 files changed

+40
-15
lines changed

packages/react-dom/src/client/ReactDOMComponent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function setInitialDOMProperties(
317317
if (canSetTextContent) {
318318
setTextContent(domElement, nextProp);
319319
}
320-
} else if (typeof nextProp === 'number') {
320+
} else if (typeof nextProp === 'number' || typeof nextProp === 'bigint') {
321321
setTextContent(domElement, '' + nextProp);
322322
}
323323
} else if (

packages/react-dom/src/client/ReactDOMHostConfig.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ export function createInstance(
254254
validateDOMNesting(type, null, hostContextDev.ancestorInfo);
255255
if (
256256
typeof props.children === 'string' ||
257-
typeof props.children === 'number'
257+
typeof props.children === 'number' ||
258+
typeof props.children === 'bigint'
258259
) {
259260
const string = '' + props.children;
260261
const ownAncestorInfo = updatedAncestorInfo(

packages/react-dom/src/server/ReactPartialRenderer.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,11 @@ function getNonChildrenInnerMarkup(props) {
294294
}
295295
} else {
296296
const content = props.children;
297-
if (typeof content === 'string' || typeof content === 'number') {
297+
if (
298+
typeof content === 'string' ||
299+
typeof content === 'number' ||
300+
typeof content === 'bigint'
301+
) {
298302
return escapeTextForBrowser(content);
299303
}
300304
}
@@ -1001,7 +1005,11 @@ class ReactDOMServerRenderer {
10011005
context: Object,
10021006
parentNamespace: string,
10031007
): string {
1004-
if (typeof child === 'string' || typeof child === 'number') {
1008+
if (
1009+
typeof child === 'string' ||
1010+
typeof child === 'number' ||
1011+
typeof child === 'bigint'
1012+
) {
10051013
const text = '' + child;
10061014
if (text === '') {
10071015
return '';

packages/react-dom/src/server/escapeTextForBrowser.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ function escapeHtml(string) {
104104
* @return {string} An escaped string.
105105
*/
106106
function escapeTextForBrowser(text) {
107-
if (typeof text === 'boolean' || typeof text === 'number') {
107+
if (
108+
typeof text === 'boolean' ||
109+
typeof text === 'number' ||
110+
typeof text === 'bigint'
111+
) {
108112
// this shortcircuit helps perf for types that we know will never have
109113
// special characters, especially given that this function is used often
110114
// for numeric dom ids.

packages/react-noop-renderer/src/createReactNoop.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
263263
throw new Error('Error in host config.');
264264
}
265265
return (
266-
typeof props.children === 'string' || typeof props.children === 'number'
266+
typeof props.children === 'string' ||
267+
typeof props.children === 'number' ||
268+
typeof props.children === 'bigint'
267269
);
268270
}
269271

packages/react-reconciler/src/ReactChildFiber.new.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ function ChildReconciler(shouldTrackSideEffects) {
490490
): Fiber | null {
491491
if (
492492
(typeof newChild === 'string' && newChild !== '') ||
493-
typeof newChild === 'number'
493+
typeof newChild === 'number' ||
494+
typeof newChild === 'bigint'
494495
) {
495496
// Text nodes don't have keys. If the previous node is implicitly keyed
496497
// we can continue to replace it without aborting even if it is not a text
@@ -567,7 +568,8 @@ function ChildReconciler(shouldTrackSideEffects) {
567568

568569
if (
569570
(typeof newChild === 'string' && newChild !== '') ||
570-
typeof newChild === 'number'
571+
typeof newChild === 'number' ||
572+
typeof newChild === 'bigint'
571573
) {
572574
// Text nodes don't have keys. If the previous node is implicitly keyed
573575
// we can continue to replace it without aborting even if it is not a text
@@ -630,7 +632,8 @@ function ChildReconciler(shouldTrackSideEffects) {
630632
): Fiber | null {
631633
if (
632634
(typeof newChild === 'string' && newChild !== '') ||
633-
typeof newChild === 'number'
635+
typeof newChild === 'number' ||
636+
typeof newChild === 'bigint'
634637
) {
635638
// Text nodes don't have keys, so we neither have to check the old nor
636639
// new node for the key. If both are text nodes, they match.
@@ -1321,7 +1324,8 @@ function ChildReconciler(shouldTrackSideEffects) {
13211324

13221325
if (
13231326
(typeof newChild === 'string' && newChild !== '') ||
1324-
typeof newChild === 'number'
1327+
typeof newChild === 'number' ||
1328+
typeof newChild === 'bigint'
13251329
) {
13261330
return placeSingleChild(
13271331
reconcileSingleTextNode(

packages/react-reconciler/src/ReactChildFiber.old.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ function ChildReconciler(shouldTrackSideEffects) {
490490
): Fiber | null {
491491
if (
492492
(typeof newChild === 'string' && newChild !== '') ||
493-
typeof newChild === 'number'
493+
typeof newChild === 'number' ||
494+
typeof newChild === 'bigint'
494495
) {
495496
// Text nodes don't have keys. If the previous node is implicitly keyed
496497
// we can continue to replace it without aborting even if it is not a text
@@ -567,7 +568,8 @@ function ChildReconciler(shouldTrackSideEffects) {
567568

568569
if (
569570
(typeof newChild === 'string' && newChild !== '') ||
570-
typeof newChild === 'number'
571+
typeof newChild === 'number' ||
572+
typeof newChild === 'bigint'
571573
) {
572574
// Text nodes don't have keys. If the previous node is implicitly keyed
573575
// we can continue to replace it without aborting even if it is not a text
@@ -630,7 +632,8 @@ function ChildReconciler(shouldTrackSideEffects) {
630632
): Fiber | null {
631633
if (
632634
(typeof newChild === 'string' && newChild !== '') ||
633-
typeof newChild === 'number'
635+
typeof newChild === 'number' ||
636+
typeof newChild === 'bigint'
634637
) {
635638
// Text nodes don't have keys, so we neither have to check the old nor
636639
// new node for the key. If both are text nodes, they match.
@@ -1321,7 +1324,8 @@ function ChildReconciler(shouldTrackSideEffects) {
13211324

13221325
if (
13231326
(typeof newChild === 'string' && newChild !== '') ||
1324-
typeof newChild === 'number'
1327+
typeof newChild === 'number' ||
1328+
typeof newChild === 'bigint'
13251329
) {
13261330
return placeSingleChild(
13271331
reconcileSingleTextNode(

packages/react-server/src/ReactFizzServer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ function renderNodeDestructiveImpl(
13521352
return;
13531353
}
13541354

1355-
if (typeof node === 'number') {
1355+
if (typeof node === 'number' || typeof node === 'bigint') {
13561356
const segment = task.blockedSegment;
13571357
segment.lastPushedText = pushTextInstance(
13581358
task.blockedSegment.chunks,

packages/react-server/src/ReactFlightServer.js

+1
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ export function resolveModelToJSON(
667667
if (
668668
typeof value === 'boolean' ||
669669
typeof value === 'number' ||
670+
typeof value === 'bigint' ||
670671
typeof value === 'undefined'
671672
) {
672673
return value;

packages/react/src/ReactChildren.js

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function mapIntoArray(
9696
switch (type) {
9797
case 'string':
9898
case 'number':
99+
case 'bigint':
99100
invokeCallback = true;
100101
break;
101102
case 'object':

0 commit comments

Comments
 (0)