Skip to content

Commit 7a2609e

Browse files
authored
Cleanup enableBigIntSupport flag (#28711)
Cleanup enableBigIntSupport flag
1 parent 4e8121a commit 7a2609e

30 files changed

+36
-129
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import {validateProperties as validateUnknownProperties} from '../shared/ReactDO
6666
import sanitizeURL from '../shared/sanitizeURL';
6767

6868
import {
69-
enableBigIntSupport,
7069
disableIEWorkarounds,
7170
enableTrustedTypesIntegration,
7271
enableFilterEmptyStringAttributesDOM,
@@ -370,10 +369,7 @@ function setProp(
370369
if (canSetTextContent) {
371370
setTextContent(domElement, value);
372371
}
373-
} else if (
374-
typeof value === 'number' ||
375-
(enableBigIntSupport && typeof value === 'bigint')
376-
) {
372+
} else if (typeof value === 'number' || typeof value === 'bigint') {
377373
if (__DEV__) {
378374
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
379375
validateTextNesting('' + value, tag);
@@ -929,10 +925,7 @@ function setPropOnCustomElement(
929925
case 'children': {
930926
if (typeof value === 'string') {
931927
setTextContent(domElement, value);
932-
} else if (
933-
typeof value === 'number' ||
934-
(enableBigIntSupport && typeof value === 'bigint')
935-
) {
928+
} else if (typeof value === 'number' || typeof value === 'bigint') {
936929
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
937930
setTextContent(domElement, '' + value);
938931
}
@@ -2948,7 +2941,7 @@ export function hydrateProperties(
29482941
if (
29492942
typeof children === 'string' ||
29502943
typeof children === 'number' ||
2951-
(enableBigIntSupport && typeof children === 'bigint')
2944+
typeof children === 'bigint'
29522945
) {
29532946
if (
29542947
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint

packages/react-dom-bindings/src/client/ReactDOMOption.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
import {Children} from 'react';
11-
import {enableBigIntSupport} from 'shared/ReactFeatureFlags';
1211

1312
let didWarnSelectedSetOnOption = false;
1413
let didWarnInvalidChild = false;
@@ -30,7 +29,7 @@ export function validateOptionProps(element: Element, props: Object) {
3029
if (
3130
typeof child === 'string' ||
3231
typeof child === 'number' ||
33-
(enableBigIntSupport && typeof child === 'bigint')
32+
typeof child === 'bigint'
3433
) {
3534
return;
3635
}

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ import {
8484
import {retryIfBlockedOn} from '../events/ReactDOMEventReplaying';
8585

8686
import {
87-
enableBigIntSupport,
8887
enableCreateEventHandleAPI,
8988
enableScopeAPI,
9089
enableTrustedTypesIntegration,
@@ -546,7 +545,7 @@ export function shouldSetTextContent(type: string, props: Props): boolean {
546545
type === 'noscript' ||
547546
typeof props.children === 'string' ||
548547
typeof props.children === 'number' ||
549-
(enableBigIntSupport && typeof props.children === 'bigint') ||
548+
typeof props.children === 'bigint' ||
550549
(typeof props.dangerouslySetInnerHTML === 'object' &&
551550
props.dangerouslySetInnerHTML !== null &&
552551
props.dangerouslySetInnerHTML.__html != null)

packages/react-dom-bindings/src/client/ToStringValue.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
import {checkFormFieldValueStringCoercion} from 'shared/CheckStringCoercion';
11-
import {enableBigIntSupport} from 'shared/ReactFeatureFlags';
1211

1312
export opaque type ToStringValue =
1413
| boolean
@@ -31,11 +30,6 @@ export function toString(value: ToStringValue): string {
3130
export function getToStringValue(value: mixed): ToStringValue {
3231
switch (typeof value) {
3332
case 'bigint':
34-
if (!enableBigIntSupport) {
35-
// bigint is assigned as empty string
36-
return '';
37-
}
38-
// fallthrough for BigInt support
3933
case 'boolean':
4034
case 'number':
4135
case 'string':

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
import {Children} from 'react';
2929

3030
import {
31-
enableBigIntSupport,
3231
enableFilterEmptyStringAttributesDOM,
3332
enableFizzExternalRuntime,
3433
} from 'shared/ReactFeatureFlags';
@@ -1664,8 +1663,7 @@ function flattenOptionChildren(children: mixed): string {
16641663
!didWarnInvalidOptionChildren &&
16651664
typeof child !== 'string' &&
16661665
typeof child !== 'number' &&
1667-
((enableBigIntSupport && typeof child !== 'bigint') ||
1668-
!enableBigIntSupport)
1666+
typeof child !== 'bigint'
16691667
) {
16701668
didWarnInvalidOptionChildren = true;
16711669
console.error(
@@ -2983,40 +2981,36 @@ function pushTitle(
29832981

29842982
if (Array.isArray(children) && children.length > 1) {
29852983
console.error(
2986-
'React expects the `children` prop of <title> tags to be a string, number%s, or object with a novel `toString` method but found an Array with length %s instead.' +
2984+
'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an Array with length %s instead.' +
29872985
' Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert `children` of <title> tags to a single string value' +
29882986
' which is why Arrays of length greater than 1 are not supported. When using JSX it can be commong to combine text nodes and value nodes.' +
29892987
' For example: <title>hello {nameOfUser}</title>. While not immediately apparent, `children` in this case is an Array with length 2. If your `children` prop' +
29902988
' is using this form try rewriting it using a template string: <title>{`hello ${nameOfUser}`}</title>.',
2991-
enableBigIntSupport ? ', bigint' : '',
29922989
children.length,
29932990
);
29942991
} else if (typeof child === 'function' || typeof child === 'symbol') {
29952992
const childType =
29962993
typeof child === 'function' ? 'a Function' : 'a Sybmol';
29972994
console.error(
2998-
'React expect children of <title> tags to be a string, number%s, or object with a novel `toString` method but found %s instead.' +
2995+
'React expect children of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found %s instead.' +
29992996
' Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title>' +
30002997
' tags to a single string value.',
3001-
enableBigIntSupport ? ', bigint' : '',
30022998
childType,
30032999
);
30043000
} else if (child && child.toString === {}.toString) {
30053001
if (child.$$typeof != null) {
30063002
console.error(
3007-
'React expects the `children` prop of <title> tags to be a string, number%s, or object with a novel `toString` method but found an object that appears to be' +
3003+
'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an object that appears to be' +
30083004
' a React element which never implements a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to' +
30093005
' be able to convert children of <title> tags to a single string value which is why rendering React elements is not supported. If the `children` of <title> is' +
30103006
' a React Component try moving the <title> tag into that component. If the `children` of <title> is some HTML markup change it to be Text only to be valid HTML.',
3011-
enableBigIntSupport ? ', bigint' : '',
30123007
);
30133008
} else {
30143009
console.error(
3015-
'React expects the `children` prop of <title> tags to be a string, number%s, or object with a novel `toString` method but found an object that does not implement' +
3010+
'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an object that does not implement' +
30163011
' a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title> tags' +
30173012
' to a single string value. Using the default `toString` method available on every object is almost certainly an error. Consider whether the `children` of this <title>' +
30183013
' is an object in error and change it to a string or number value if so. Otherwise implement a `toString` method that React can use to produce a valid <title>.',
3019-
enableBigIntSupport ? ', bigint' : '',
30203014
);
30213015
}
30223016
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
*/
4040

4141
import {checkHtmlStringCoercion} from 'shared/CheckStringCoercion';
42-
import {enableBigIntSupport} from 'shared/ReactFeatureFlags';
4342

4443
const matchHtmlRegExp = /["'&<>]/;
4544

@@ -110,7 +109,7 @@ function escapeTextForBrowser(text: string | number | boolean): string {
110109
if (
111110
typeof text === 'boolean' ||
112111
typeof text === 'number' ||
113-
(enableBigIntSupport && typeof text === 'bigint')
112+
typeof text === 'bigint'
114113
) {
115114
// this shortcircuit helps perf for types that we know will never have
116115
// special characters, especially given that this function is used often

packages/react-dom/src/__tests__/ReactDOMFiber-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ describe('ReactDOMFiber', () => {
6060
expect(container.textContent).toEqual('10');
6161
});
6262

63-
// @gate enableBigIntSupport
6463
it('should render bigints as children', async () => {
6564
const Box = ({value}) => <div>{value}</div>;
6665

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,7 +3377,6 @@ describe('ReactDOMFizzServer', () => {
33773377
);
33783378
});
33793379

3380-
// @gate enableBigIntSupport
33813380
it('Supports bigint', async () => {
33823381
await act(async () => {
33833382
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
@@ -5732,9 +5731,7 @@ describe('ReactDOMFizzServer', () => {
57325731
pipe(writable);
57335732
});
57345733
}).toErrorDev([
5735-
'React expects the `children` prop of <title> tags to be a string, number' +
5736-
gate(flags => (flags.enableBigIntSupport ? ', bigint' : '')) +
5737-
', or object with a novel `toString` method but found an Array with length 2 instead. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert `children` of <title> tags to a single string value which is why Arrays of length greater than 1 are not supported. When using JSX it can be commong to combine text nodes and value nodes. For example: <title>hello {nameOfUser}</title>. While not immediately apparent, `children` in this case is an Array with length 2. If your `children` prop is using this form try rewriting it using a template string: <title>{`hello ${nameOfUser}`}</title>.',
5734+
'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an Array with length 2 instead. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert `children` of <title> tags to a single string value which is why Arrays of length greater than 1 are not supported. When using JSX it can be commong to combine text nodes and value nodes. For example: <title>hello {nameOfUser}</title>. While not immediately apparent, `children` in this case is an Array with length 2. If your `children` prop is using this form try rewriting it using a template string: <title>{`hello ${nameOfUser}`}</title>.',
57385735
]);
57395736

57405737
expect(getVisibleChildren(document.head)).toEqual(<title />);
@@ -5771,9 +5768,7 @@ describe('ReactDOMFizzServer', () => {
57715768
pipe(writable);
57725769
});
57735770
}).toErrorDev([
5774-
'React expects the `children` prop of <title> tags to be a string, number' +
5775-
gate(flags => (flags.enableBigIntSupport ? ', bigint' : '')) +
5776-
', or object with a novel `toString` method but found an object that appears to be a React element which never implements a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title> tags to a single string value which is why rendering React elements is not supported. If the `children` of <title> is a React Component try moving the <title> tag into that component. If the `children` of <title> is some HTML markup change it to be Text only to be valid HTML.',
5771+
'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an object that appears to be a React element which never implements a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title> tags to a single string value which is why rendering React elements is not supported. If the `children` of <title> is a React Component try moving the <title> tag into that component. If the `children` of <title> is some HTML markup change it to be Text only to be valid HTML.',
57775772
]);
57785773
// object titles are toStringed when float is on
57795774
expect(getVisibleChildren(document.head)).toEqual(
@@ -5808,9 +5803,7 @@ describe('ReactDOMFizzServer', () => {
58085803
pipe(writable);
58095804
});
58105805
}).toErrorDev([
5811-
'React expects the `children` prop of <title> tags to be a string, number' +
5812-
gate(flags => (flags.enableBigIntSupport ? ', bigint' : '')) +
5813-
', or object with a novel `toString` method but found an object that does not implement a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title> tags to a single string value. Using the default `toString` method available on every object is almost certainly an error. Consider whether the `children` of this <title> is an object in error and change it to a string or number value if so. Otherwise implement a `toString` method that React can use to produce a valid <title>.',
5806+
'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an object that does not implement a suitable `toString` method. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert children of <title> tags to a single string value. Using the default `toString` method available on every object is almost certainly an error. Consider whether the `children` of this <title> is an object in error and change it to a string or number value if so. Otherwise implement a `toString` method that React can use to produce a valid <title>.',
58145807
]);
58155808
// object titles are toStringed when float is on
58165809
expect(getVisibleChildren(document.head)).toEqual(

packages/react-dom/src/__tests__/ReactDOMInput-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ describe('ReactDOMInput', () => {
846846
expect(node.value).toBe('0');
847847
});
848848

849-
// @gate enableBigIntSupport
850849
it('should display `value` of bigint 5', async () => {
851850
await act(() => {
852851
root.render(<input type="text" value={5n} onChange={emptyFunction} />);

packages/react-dom/src/__tests__/ReactDOMOption-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ describe('ReactDOMOption', () => {
171171
expect(container.firstChild.value).toBe('hello');
172172
});
173173

174-
// @gate enableBigIntSupport
175174
it('should support bigint values', async () => {
176175
const container = await renderIntoDocument(<option>{5n}</option>);
177176
expect(container.firstChild.innerHTML).toBe('5');

0 commit comments

Comments
 (0)