Skip to content

Commit

Permalink
bigint-render-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jul 2, 2022
1 parent b3f037c commit aaa4d38
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function setInitialDOMProperties(
if (canSetTextContent) {
setTextContent(domElement, nextProp);
}
} else if (typeof nextProp === 'number') {
} else if (typeof nextProp === 'number' || typeof nextProp === 'bigint') {
setTextContent(domElement, '' + nextProp);
}
} else if (
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ export function createInstance(
validateDOMNesting(type, null, hostContextDev.ancestorInfo);
if (
typeof props.children === 'string' ||
typeof props.children === 'number'
typeof props.children === 'number' ||
typeof props.children === 'bigint'
) {
const string = '' + props.children;
const ownAncestorInfo = updatedAncestorInfo(
Expand Down
12 changes: 10 additions & 2 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ function getNonChildrenInnerMarkup(props) {
}
} else {
const content = props.children;
if (typeof content === 'string' || typeof content === 'number') {
if (
typeof content === 'string' ||
typeof content === 'number' ||
typeof content === 'bigint'
) {
return escapeTextForBrowser(content);
}
}
Expand Down Expand Up @@ -1001,7 +1005,11 @@ class ReactDOMServerRenderer {
context: Object,
parentNamespace: string,
): string {
if (typeof child === 'string' || typeof child === 'number') {
if (
typeof child === 'string' ||
typeof child === 'number' ||
typeof child === 'bigint'
) {
const text = '' + child;
if (text === '') {
return '';
Expand Down
6 changes: 5 additions & 1 deletion packages/react-dom/src/server/escapeTextForBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ function escapeHtml(string) {
* @return {string} An escaped string.
*/
function escapeTextForBrowser(text) {
if (typeof text === 'boolean' || typeof text === 'number') {
if (
typeof text === 'boolean' ||
typeof text === 'number' ||
typeof text === 'bigint'
) {
// this shortcircuit helps perf for types that we know will never have
// special characters, especially given that this function is used often
// for numeric dom ids.
Expand Down
4 changes: 3 additions & 1 deletion packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
throw new Error('Error in host config.');
}
return (
typeof props.children === 'string' || typeof props.children === 'number'
typeof props.children === 'string' ||
typeof props.children === 'number' ||
typeof props.children === 'bigint'
);
}

Expand Down
12 changes: 8 additions & 4 deletions packages/react-reconciler/src/ReactChildFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ function ChildReconciler(shouldTrackSideEffects) {
): Fiber | null {
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
// Text nodes don't have keys. If the previous node is implicitly keyed
// we can continue to replace it without aborting even if it is not a text
Expand Down Expand Up @@ -567,7 +568,8 @@ function ChildReconciler(shouldTrackSideEffects) {

if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
// Text nodes don't have keys. If the previous node is implicitly keyed
// we can continue to replace it without aborting even if it is not a text
Expand Down Expand Up @@ -630,7 +632,8 @@ function ChildReconciler(shouldTrackSideEffects) {
): Fiber | null {
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
// Text nodes don't have keys, so we neither have to check the old nor
// new node for the key. If both are text nodes, they match.
Expand Down Expand Up @@ -1321,7 +1324,8 @@ function ChildReconciler(shouldTrackSideEffects) {

if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
return placeSingleChild(
reconcileSingleTextNode(
Expand Down
12 changes: 8 additions & 4 deletions packages/react-reconciler/src/ReactChildFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ function ChildReconciler(shouldTrackSideEffects) {
): Fiber | null {
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
// Text nodes don't have keys. If the previous node is implicitly keyed
// we can continue to replace it without aborting even if it is not a text
Expand Down Expand Up @@ -567,7 +568,8 @@ function ChildReconciler(shouldTrackSideEffects) {

if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
// Text nodes don't have keys. If the previous node is implicitly keyed
// we can continue to replace it without aborting even if it is not a text
Expand Down Expand Up @@ -630,7 +632,8 @@ function ChildReconciler(shouldTrackSideEffects) {
): Fiber | null {
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
// Text nodes don't have keys, so we neither have to check the old nor
// new node for the key. If both are text nodes, they match.
Expand Down Expand Up @@ -1321,7 +1324,8 @@ function ChildReconciler(shouldTrackSideEffects) {

if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number'
typeof newChild === 'number' ||
typeof newChild === 'bigint'
) {
return placeSingleChild(
reconcileSingleTextNode(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ function renderNodeDestructiveImpl(
return;
}

if (typeof node === 'number') {
if (typeof node === 'number' || typeof node === 'bigint') {
const segment = task.blockedSegment;
segment.lastPushedText = pushTextInstance(
task.blockedSegment.chunks,
Expand Down
1 change: 1 addition & 0 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ export function resolveModelToJSON(
if (
typeof value === 'boolean' ||
typeof value === 'number' ||
typeof value === 'bigint' ||
typeof value === 'undefined'
) {
return value;
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/ReactChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function mapIntoArray(
switch (type) {
case 'string':
case 'number':
case 'bigint':
invokeCallback = true;
break;
case 'object':
Expand Down

0 comments on commit aaa4d38

Please sign in to comment.