Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup enableBigIntSupport flag #28711

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import {validateProperties as validateUnknownProperties} from '../shared/ReactDO
import sanitizeURL from '../shared/sanitizeURL';

import {
enableBigIntSupport,
disableIEWorkarounds,
enableTrustedTypesIntegration,
enableFilterEmptyStringAttributesDOM,
Expand Down Expand Up @@ -370,10 +369,7 @@ function setProp(
if (canSetTextContent) {
setTextContent(domElement, value);
}
} else if (
typeof value === 'number' ||
(enableBigIntSupport && typeof value === 'bigint')
) {
} else if (typeof value === 'number' || typeof value === 'bigint') {
if (__DEV__) {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
validateTextNesting('' + value, tag);
Expand Down Expand Up @@ -929,10 +925,7 @@ function setPropOnCustomElement(
case 'children': {
if (typeof value === 'string') {
setTextContent(domElement, value);
} else if (
typeof value === 'number' ||
(enableBigIntSupport && typeof value === 'bigint')
) {
} else if (typeof value === 'number' || typeof value === 'bigint') {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
setTextContent(domElement, '' + value);
}
Expand Down Expand Up @@ -2948,7 +2941,7 @@ export function hydrateProperties(
if (
typeof children === 'string' ||
typeof children === 'number' ||
(enableBigIntSupport && typeof children === 'bigint')
typeof children === 'bigint'
) {
if (
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
Expand Down
3 changes: 1 addition & 2 deletions packages/react-dom-bindings/src/client/ReactDOMOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import {Children} from 'react';
import {enableBigIntSupport} from 'shared/ReactFeatureFlags';

let didWarnSelectedSetOnOption = false;
let didWarnInvalidChild = false;
Expand All @@ -30,7 +29,7 @@ export function validateOptionProps(element: Element, props: Object) {
if (
typeof child === 'string' ||
typeof child === 'number' ||
(enableBigIntSupport && typeof child === 'bigint')
typeof child === 'bigint'
) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ import {
import {retryIfBlockedOn} from '../events/ReactDOMEventReplaying';

import {
enableBigIntSupport,
enableCreateEventHandleAPI,
enableScopeAPI,
enableTrustedTypesIntegration,
Expand Down Expand Up @@ -546,7 +545,7 @@ export function shouldSetTextContent(type: string, props: Props): boolean {
type === 'noscript' ||
typeof props.children === 'string' ||
typeof props.children === 'number' ||
(enableBigIntSupport && typeof props.children === 'bigint') ||
typeof props.children === 'bigint' ||
(typeof props.dangerouslySetInnerHTML === 'object' &&
props.dangerouslySetInnerHTML !== null &&
props.dangerouslySetInnerHTML.__html != null)
Expand Down
6 changes: 0 additions & 6 deletions packages/react-dom-bindings/src/client/ToStringValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import {checkFormFieldValueStringCoercion} from 'shared/CheckStringCoercion';
import {enableBigIntSupport} from 'shared/ReactFeatureFlags';

export opaque type ToStringValue =
| boolean
Expand All @@ -31,11 +30,6 @@ export function toString(value: ToStringValue): string {
export function getToStringValue(value: mixed): ToStringValue {
switch (typeof value) {
case 'bigint':
if (!enableBigIntSupport) {
// bigint is assigned as empty string
return '';
}
// fallthrough for BigInt support
case 'boolean':
case 'number':
case 'string':
Expand Down
16 changes: 5 additions & 11 deletions packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
import {Children} from 'react';

import {
enableBigIntSupport,
enableFilterEmptyStringAttributesDOM,
enableFizzExternalRuntime,
} from 'shared/ReactFeatureFlags';
Expand Down Expand Up @@ -1664,8 +1663,7 @@ function flattenOptionChildren(children: mixed): string {
!didWarnInvalidOptionChildren &&
typeof child !== 'string' &&
typeof child !== 'number' &&
((enableBigIntSupport && typeof child !== 'bigint') ||
!enableBigIntSupport)
typeof child !== 'bigint'
) {
didWarnInvalidOptionChildren = true;
console.error(
Expand Down Expand Up @@ -2983,40 +2981,36 @@ function pushTitle(

if (Array.isArray(children) && children.length > 1) {
console.error(
'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.' +
'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.' +
' 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>.',
enableBigIntSupport ? ', bigint' : '',
children.length,
);
} else if (typeof child === 'function' || typeof child === 'symbol') {
const childType =
typeof child === 'function' ? 'a Function' : 'a Sybmol';
console.error(
'React expect children of <title> tags to be a string, number%s, or object with a novel `toString` method but found %s instead.' +
'React expect children of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found %s 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.',
enableBigIntSupport ? ', bigint' : '',
childType,
);
} else if (child && child.toString === {}.toString) {
if (child.$$typeof != null) {
console.error(
'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' +
'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.',
enableBigIntSupport ? ', bigint' : '',
);
} else {
console.error(
'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' +
'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>.',
enableBigIntSupport ? ', bigint' : '',
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
*/

import {checkHtmlStringCoercion} from 'shared/CheckStringCoercion';
import {enableBigIntSupport} from 'shared/ReactFeatureFlags';

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

Expand Down Expand Up @@ -110,7 +109,7 @@ function escapeTextForBrowser(text: string | number | boolean): string {
if (
typeof text === 'boolean' ||
typeof text === 'number' ||
(enableBigIntSupport && typeof text === 'bigint')
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
Expand Down
1 change: 0 additions & 1 deletion packages/react-dom/src/__tests__/ReactDOMFiber-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('ReactDOMFiber', () => {
expect(container.textContent).toEqual('10');
});

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

Expand Down
13 changes: 3 additions & 10 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3377,7 +3377,6 @@ describe('ReactDOMFizzServer', () => {
);
});

// @gate enableBigIntSupport
it('Supports bigint', async () => {
await act(async () => {
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
Expand Down Expand Up @@ -5732,9 +5731,7 @@ describe('ReactDOMFizzServer', () => {
pipe(writable);
});
}).toErrorDev([
'React expects the `children` prop of <title> tags to be a string, number' +
gate(flags => (flags.enableBigIntSupport ? ', 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>.',
'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>.',
]);

expect(getVisibleChildren(document.head)).toEqual(<title />);
Expand Down Expand Up @@ -5771,9 +5768,7 @@ describe('ReactDOMFizzServer', () => {
pipe(writable);
});
}).toErrorDev([
'React expects the `children` prop of <title> tags to be a string, number' +
gate(flags => (flags.enableBigIntSupport ? ', 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.',
'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.',
]);
// object titles are toStringed when float is on
expect(getVisibleChildren(document.head)).toEqual(
Expand Down Expand Up @@ -5808,9 +5803,7 @@ describe('ReactDOMFizzServer', () => {
pipe(writable);
});
}).toErrorDev([
'React expects the `children` prop of <title> tags to be a string, number' +
gate(flags => (flags.enableBigIntSupport ? ', 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>.',
'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>.',
]);
// object titles are toStringed when float is on
expect(getVisibleChildren(document.head)).toEqual(
Expand Down
1 change: 0 additions & 1 deletion packages/react-dom/src/__tests__/ReactDOMInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,6 @@ describe('ReactDOMInput', () => {
expect(node.value).toBe('0');
});

// @gate enableBigIntSupport
it('should display `value` of bigint 5', async () => {
await act(() => {
root.render(<input type="text" value={5n} onChange={emptyFunction} />);
Expand Down
1 change: 0 additions & 1 deletion packages/react-dom/src/__tests__/ReactDOMOption-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ describe('ReactDOMOption', () => {
expect(container.firstChild.value).toBe('hello');
});

// @gate enableBigIntSupport
it('should support bigint values', async () => {
const container = await renderIntoDocument(<option>{5n}</option>);
expect(container.firstChild.innerHTML).toBe('5');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ describe('ReactDOMServerIntegration', () => {

itRenders('a bigint', async render => {
const e = await render(42n);
if (gate(flags => flags.enableBigIntSupport)) {
expect(e.nodeType).toBe(3);
expect(e.nodeValue).toMatch('42');
} else {
expect(e).toBe(null);
}
expect(e.nodeType).toBe(3);
expect(e.nodeValue).toMatch('42');
});

itRenders('an array with one child', async render => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ function initModules() {
};
}

const {resetModules, itRenders, serverRender, streamRender} =
ReactDOMServerIntegrationUtils(initModules);
const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules);

// TODO: Run this in React Fire mode after we figure out the SSR behavior.
const desc = disableInputAttributeSyncing ? xdescribe : describe;
Expand All @@ -49,13 +48,7 @@ desc('ReactDOMServerIntegrationInput', () => {

itRenders('an input with a bigint value and an onChange', async render => {
const e = await render(<input value={5n} onChange={() => {}} />);
expect(e.value).toBe(
gate(flags => flags.enableBigIntSupport) ||
render === serverRender ||
render === streamRender
? '5'
: '',
);
expect(e.value).toBe('5');
});

itRenders('an input with a value and readOnly', async render => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ describe('ReactDOMServerIntegrationSelect', () => {
</select>,
);
const option = e.options[0];
expect(option.textContent).toBe(
gate(flags => flags.enableBigIntSupport) ? 'A B 5' : 'A B ',
);
expect(option.textContent).toBe('A B 5');
expect(option.value).toBe('bar');
expect(option.selected).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ function initModules() {
};
}

const {resetModules, itRenders, serverRender, streamRender} =
ReactDOMServerIntegrationUtils(initModules);
const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules);

describe('ReactDOMServerIntegrationTextarea', () => {
beforeEach(() => {
Expand All @@ -51,13 +50,7 @@ describe('ReactDOMServerIntegrationTextarea', () => {
itRenders('a textarea with a bigint value and an onChange', async render => {
const e = await render(<textarea value={5n} onChange={() => {}} />);
expect(e.getAttribute('value')).toBe(null);
expect(e.value).toBe(
gate(flags => flags.enableBigIntSupport) ||
render === serverRender ||
render === streamRender
? '5'
: '',
);
expect(e.value).toBe('5');
});

itRenders('a textarea with a value of undefined', async render => {
Expand Down
1 change: 0 additions & 1 deletion packages/react-dom/src/__tests__/ReactDOMTextarea-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ describe('ReactDOMTextarea', () => {
expect(node.value).toBe('0');
});

// @gate enableBigIntSupport
it('should display `defaultValue` of bigint 0', async () => {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ describe('ReactMultiChildText', () => {
]);
});

// @gate enableBigIntSupport
it('should correctly handle bigint children for render and update', async () => {
// prettier-ignore
await testAllPermutations([
Expand Down
9 changes: 4 additions & 5 deletions packages/react-reconciler/src/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
Forked,
PlacementDEV,
} from './ReactFiberFlags';
import {enableBigIntSupport} from 'shared/ReactFeatureFlags';
import {
getIteratorFn,
REACT_ELEMENT_TYPE,
Expand Down Expand Up @@ -658,7 +657,7 @@ function createChildReconciler(
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number' ||
(enableBigIntSupport && typeof newChild === 'bigint')
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 @@ -780,7 +779,7 @@ function createChildReconciler(
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number' ||
(enableBigIntSupport && typeof newChild === 'bigint')
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 @@ -905,7 +904,7 @@ function createChildReconciler(
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number' ||
(enableBigIntSupport && typeof newChild === 'bigint')
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 @@ -1722,7 +1721,7 @@ function createChildReconciler(
if (
(typeof newChild === 'string' && newChild !== '') ||
typeof newChild === 'number' ||
(enableBigIntSupport && typeof newChild === 'bigint')
typeof newChild === 'bigint'
) {
return placeSingleChild(
reconcileSingleTextNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('ReactTopLevelText', () => {
expect(ReactNoop).toMatchRenderedOutput('10');
});

// @gate enableBigIntSupport
it('should render a component returning bigints directly from render', async () => {
const Text = ({value}) => value;
ReactNoop.render(<Text value={10n} />);
Expand Down
Loading