{}} />);
@@ -2429,12 +2429,12 @@ describe('ReactDOMComponent', () => {
expect(el.hasAttribute('whatever')).toBe(false);
});
- it('will assign an object custom attributes', function() {
+ it('will assign an object custom attributes', function () {
const el = ReactTestUtils.renderIntoDocument(
);
expect(el.getAttribute('whatever')).toBe('[object Object]');
});
- it('allows Temporal-like objects as HTML (they are not coerced to strings first)', function() {
+ it('allows Temporal-like objects as HTML (they are not coerced to strings first)', function () {
class TemporalLike {
valueOf() {
// Throwing here is the behavior of ECMAScript "Temporal" date/time API.
@@ -2456,7 +2456,7 @@ describe('ReactDOMComponent', () => {
expect(container.firstChild.innerHTML).toEqual('2020-01-01');
});
- it('allows cased data attributes', function() {
+ it('allows cased data attributes', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
);
@@ -2471,7 +2471,7 @@ describe('ReactDOMComponent', () => {
expect(el.getAttribute('data-foobar')).toBe('true');
});
- it('allows cased custom attributes', function() {
+ it('allows cased custom attributes', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
);
@@ -2486,7 +2486,7 @@ describe('ReactDOMComponent', () => {
expect(el.getAttribute('foobar')).toBe('true');
});
- it('warns on NaN attributes', function() {
+ it('warns on NaN attributes', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
);
@@ -2498,7 +2498,7 @@ describe('ReactDOMComponent', () => {
expect(el.getAttribute('whatever')).toBe('NaN');
});
- it('removes a property when it becomes invalid', function() {
+ it('removes a property when it becomes invalid', function () {
const container = document.createElement('div');
ReactDOM.render(
, container);
expect(() =>
@@ -2508,7 +2508,7 @@ describe('ReactDOMComponent', () => {
expect(el.hasAttribute('whatever')).toBe(false);
});
- it('warns on bad casing of known HTML attributes', function() {
+ it('warns on bad casing of known HTML attributes', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
);
@@ -2520,8 +2520,8 @@ describe('ReactDOMComponent', () => {
});
});
- describe('Object stringification', function() {
- it('allows objects on known properties', function() {
+ describe('Object stringification', function () {
+ it('allows objects on known properties', function () {
const el = ReactTestUtils.renderIntoDocument(
);
expect(el.getAttribute('accept-charset')).toBe('[object Object]');
});
@@ -2564,7 +2564,7 @@ describe('ReactDOMComponent', () => {
);
});
- it('allows objects that inherit a custom toString method', function() {
+ it('allows objects that inherit a custom toString method', function () {
const parent = {toString: () => 'hello.jpg'};
const child = Object.create(parent);
const el = ReactTestUtils.renderIntoDocument(
);
@@ -2572,7 +2572,7 @@ describe('ReactDOMComponent', () => {
expect(el.src).toBe('http://localhost/hello.jpg');
});
- it('assigns ajaxify (an important internal FB attribute)', function() {
+ it('assigns ajaxify (an important internal FB attribute)', function () {
const options = {toString: () => 'ajaxy'};
const el = ReactTestUtils.renderIntoDocument(
);
@@ -2580,8 +2580,8 @@ describe('ReactDOMComponent', () => {
});
});
- describe('String boolean attributes', function() {
- it('does not assign string boolean attributes for custom attributes', function() {
+ describe('String boolean attributes', function () {
+ it('does not assign string boolean attributes for custom attributes', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
);
@@ -2594,19 +2594,19 @@ describe('ReactDOMComponent', () => {
expect(el.hasAttribute('whatever')).toBe(false);
});
- it('stringifies the boolean true for allowed attributes', function() {
+ it('stringifies the boolean true for allowed attributes', function () {
const el = ReactTestUtils.renderIntoDocument(
);
expect(el.getAttribute('spellCheck')).toBe('true');
});
- it('stringifies the boolean false for allowed attributes', function() {
+ it('stringifies the boolean false for allowed attributes', function () {
const el = ReactTestUtils.renderIntoDocument(
);
expect(el.getAttribute('spellCheck')).toBe('false');
});
- it('stringifies implicit booleans for allowed attributes', function() {
+ it('stringifies implicit booleans for allowed attributes', function () {
// eslint-disable-next-line react/jsx-boolean-value
const el = ReactTestUtils.renderIntoDocument(
);
@@ -2614,8 +2614,8 @@ describe('ReactDOMComponent', () => {
});
});
- describe('Boolean attributes', function() {
- it('warns on the ambiguous string value "false"', function() {
+ describe('Boolean attributes', function () {
+ it('warns on the ambiguous string value "false"', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
);
@@ -2628,7 +2628,7 @@ describe('ReactDOMComponent', () => {
expect(el.getAttribute('hidden')).toBe('');
});
- it('warns on the potentially-ambiguous string value "true"', function() {
+ it('warns on the potentially-ambiguous string value "true"', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
);
@@ -2642,8 +2642,8 @@ describe('ReactDOMComponent', () => {
});
});
- describe('Hyphenated SVG elements', function() {
- it('the font-face element is not a custom element', function() {
+ describe('Hyphenated SVG elements', function () {
+ it('the font-face element is not a custom element', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
@@ -2660,7 +2660,7 @@ describe('ReactDOMComponent', () => {
);
});
- it('the font-face element does not allow unknown boolean values', function() {
+ it('the font-face element does not allow unknown boolean values', function () {
let el;
expect(() => {
el = ReactTestUtils.renderIntoDocument(
diff --git a/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js b/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js
index e19ae0529e0bd..12d34a34a4ea3 100644
--- a/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js
@@ -190,9 +190,7 @@ describe('ReactDOMComponentTree', () => {
it('finds instance of node that is attempted to be unmounted', () => {
const component =
;
const node = ReactDOM.render(
{component}
, container);
- expect(() =>
- ReactDOM.unmountComponentAtNode(node),
- ).toErrorDev(
+ expect(() => ReactDOM.unmountComponentAtNode(node)).toErrorDev(
"unmountComponentAtNode(): The node you're attempting to unmount " +
'was rendered by React and is not a top-level container. You may ' +
'have accidentally passed in a React root node instead of its ' +
@@ -209,9 +207,7 @@ describe('ReactDOMComponentTree', () => {
);
const anotherComponent =
;
const instance = ReactDOM.render(component, container);
- expect(() =>
- ReactDOM.render(anotherComponent, instance),
- ).toErrorDev(
+ expect(() => ReactDOM.render(anotherComponent, instance)).toErrorDev(
'render(...): Replacing React-rendered children with a new root ' +
'component. If you intended to update the children of this node, ' +
'you should instead have the existing children update their state ' +
diff --git a/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js b/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js
index 799340014b961..4e02de9f2ef8e 100644
--- a/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js
@@ -37,7 +37,7 @@ describe('ReactDOMConsoleErrorReporting', () => {
return this.props.children;
}
};
- NoError = function() {
+ NoError = function () {
return
OK
;
};
container = document.createElement('div');
diff --git a/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js b/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js
index 87bfec0c171fc..ff3e33390ecd7 100644
--- a/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js
@@ -401,7 +401,7 @@ describe('ReactDOMEventListener', () => {
const originalDocAddEventListener = document.addEventListener;
const originalRootAddEventListener = container.addEventListener;
- document.addEventListener = function(type) {
+ document.addEventListener = function (type) {
switch (type) {
case 'selectionchange':
break;
@@ -411,7 +411,7 @@ describe('ReactDOMEventListener', () => {
);
}
};
- container.addEventListener = function(type, fn, options) {
+ container.addEventListener = function (type, fn, options) {
if (options && (options === true || options.capture)) {
return;
}
@@ -981,7 +981,7 @@ describe('ReactDOMEventListener', () => {
const log = [];
const originalDocAddEventListener = document.addEventListener;
- document.addEventListener = function(type, fn, options) {
+ document.addEventListener = function (type, fn, options) {
switch (type) {
case 'selectionchange':
log.push(options);
diff --git a/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js b/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js
index f74237031f50f..e7238c07608c4 100644
--- a/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js
@@ -14,7 +14,7 @@ describe('ReactDOMEventListener', () => {
let container;
beforeEach(() => {
- window.TextEvent = function() {};
+ window.TextEvent = function () {};
jest.resetModules();
React = require('react');
jest.isolateModules(() => {
diff --git a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js
index c8dc164ba8396..b342cc9461522 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js
@@ -206,11 +206,11 @@ describe('ReactDOMFiber', () => {
const expectHTML = {ref: el => htmlEls.push(el)};
const expectMath = {ref: el => mathEls.push(el)};
- const usePortal = function(tree) {
+ const usePortal = function (tree) {
return ReactDOM.createPortal(tree, document.createElement('div'));
};
- const assertNamespacesMatch = function(tree) {
+ const assertNamespacesMatch = function (tree) {
const testContainer = document.createElement('div');
svgEls = [];
htmlEls = [];
@@ -1213,9 +1213,7 @@ describe('ReactDOMFiber', () => {
expect(container.innerHTML).toBe('
bar
');
// then we mess with the DOM before an update
container.innerHTML = '
MEOW.
';
- expect(() =>
- ReactDOM.render(
baz
, container),
- ).toErrorDev(
+ expect(() => ReactDOM.render(
baz
, container)).toErrorDev(
'render(...): ' +
'It looks like the React-rendered content of this container was ' +
'removed without using React. This is not supported and will ' +
@@ -1232,9 +1230,7 @@ describe('ReactDOMFiber', () => {
expect(container.innerHTML).toBe('
bar
');
// then we mess with the DOM before an update
container.innerHTML = '';
- expect(() =>
- ReactDOM.render(
baz
, container),
- ).toErrorDev(
+ expect(() => ReactDOM.render(
baz
, container)).toErrorDev(
'render(...): ' +
'It looks like the React-rendered content of this container was ' +
'removed without using React. This is not supported and will ' +
diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
index e314cbae13d1f..a21e1d593cabc 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
@@ -66,8 +66,8 @@ describe('ReactDOMFizzServer', () => {
);
}
useSyncExternalStore = React.useSyncExternalStore;
- useSyncExternalStoreWithSelector = require('use-sync-external-store/with-selector')
- .useSyncExternalStoreWithSelector;
+ useSyncExternalStoreWithSelector =
+ require('use-sync-external-store/with-selector').useSyncExternalStoreWithSelector;
textCache = new Map();
@@ -519,7 +519,7 @@ describe('ReactDOMFizzServer', () => {
let bootstrapped = false;
const errors = [];
- window.__INIT__ = function() {
+ window.__INIT__ = function () {
bootstrapped = true;
// Attempt to hydrate the content.
ReactDOMClient.hydrateRoot(container,
, {
@@ -904,7 +904,7 @@ describe('ReactDOMFizzServer', () => {
}
let bootstrapped = false;
- window.__INIT__ = function() {
+ window.__INIT__ = function () {
bootstrapped = true;
// Attempt to hydrate the content.
ReactDOMClient.hydrateRoot(container,
);
@@ -1512,7 +1512,7 @@ describe('ReactDOMFizzServer', () => {
function normalizeCodeLocInfo(str) {
return (
str &&
- str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function(m, name) {
+ str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function (m, name) {
return '\n in ' + name + ' (at **)';
})
);
diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js
index fc795649ee956..338e51c22474b 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js
@@ -10,7 +10,8 @@
'use strict';
// Polyfills for test environment
-global.ReadableStream = require('web-streams-polyfill/ponyfill/es6').ReadableStream;
+global.ReadableStream =
+ require('web-streams-polyfill/ponyfill/es6').ReadableStream;
global.TextEncoder = require('util').TextEncoder;
let React;
diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js
index d55b11154f280..43fe7ec09b78e 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js
@@ -10,7 +10,8 @@
'use strict';
// Polyfills for test environment
-global.ReadableStream = require('web-streams-polyfill/ponyfill/es6').ReadableStream;
+global.ReadableStream =
+ require('web-streams-polyfill/ponyfill/es6').ReadableStream;
global.TextEncoder = require('util').TextEncoder;
let React;
diff --git a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js
index b216700671cca..cdc271f879991 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js
@@ -79,7 +79,7 @@ describe('ReactDOMFloat', () => {
function normalizeCodeLocInfo(str) {
return (
typeof str === 'string' &&
- str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function(m, name) {
+ str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function (m, name) {
return '\n in ' + name + ' (at **)';
})
);
diff --git a/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js b/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js
index 4bdb5957f4a39..65a3936987b17 100644
--- a/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js
@@ -38,7 +38,7 @@ describe('ReactDOMServerHydration', () => {
function normalizeCodeLocInfo(str) {
return (
typeof str === 'string' &&
- str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function(m, name) {
+ str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function (m, name) {
return '\n in ' + name + ' (at **)';
})
);
diff --git a/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js
index f417fea57a58f..717d795d99884 100644
--- a/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js
@@ -192,7 +192,7 @@ describe('ReactDOMImageLoad', () => {
);
});
- it('captures the load event if it happens before commit phase and replays it between layout and passive effects', async function() {
+ it('captures the load event if it happens before commit phase and replays it between layout and passive effects', async function () {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
@@ -232,7 +232,7 @@ describe('ReactDOMImageLoad', () => {
expect(onLoadSpy).toHaveBeenCalled();
});
- it('captures the load event if it happens after commit phase and replays it', async function() {
+ it('captures the load event if it happens after commit phase and replays it', async function () {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
@@ -262,7 +262,7 @@ describe('ReactDOMImageLoad', () => {
expect(onLoadSpy).toHaveBeenCalledTimes(1);
});
- it('it replays the last load event when more than one fire before the end of the layout phase completes', async function() {
+ it('it replays the last load event when more than one fire before the end of the layout phase completes', async function () {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
@@ -313,7 +313,7 @@ describe('ReactDOMImageLoad', () => {
expect(onLoadSpy).toHaveBeenCalledTimes(1);
});
- it('replays load events that happen in passive phase after the passive phase.', async function() {
+ it('replays load events that happen in passive phase after the passive phase.', async function () {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
@@ -339,7 +339,7 @@ describe('ReactDOMImageLoad', () => {
expect(onLoadSpy).toHaveBeenCalledTimes(1);
});
- it('captures and suppresses the load event if it happens before passive effects and a cascading update causes the img to be removed', async function() {
+ it('captures and suppresses the load event if it happens before passive effects and a cascading update causes the img to be removed', async function () {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
@@ -388,7 +388,7 @@ describe('ReactDOMImageLoad', () => {
expect(onLoadSpy).not.toHaveBeenCalled();
});
- it('captures and suppresses the load event if it happens before passive effects and a cascading update causes the img to be removed, alternate', async function() {
+ it('captures and suppresses the load event if it happens before passive effects and a cascading update causes the img to be removed, alternate', async function () {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
@@ -517,7 +517,7 @@ describe('ReactDOMImageLoad', () => {
// expect(onLoadSpy).toHaveBeenCalledTimes(1);
// });
- it('correctly replays the last img load even when a yield + update causes the host element to change', async function() {
+ it('correctly replays the last img load even when a yield + update causes the host element to change', async function () {
let externalSetSrc = null;
let externalSetSrcAlt = null;
diff --git a/packages/react-dom/src/__tests__/ReactDOMInput-test.js b/packages/react-dom/src/__tests__/ReactDOMInput-test.js
index c7a167391f253..d75c4ded9e458 100644
--- a/packages/react-dom/src/__tests__/ReactDOMInput-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMInput-test.js
@@ -333,26 +333,26 @@ describe('ReactDOMInput', () => {
expect(node.value).toEqual('0');
});
- it('updates the value on radio buttons from "" to 0', function() {
+ it('updates the value on radio buttons from "" to 0', function () {
ReactDOM.render(
-
,
+
,
container,
);
ReactDOM.render(
-
,
+
,
container,
);
expect(container.firstChild.value).toBe('0');
expect(container.firstChild.getAttribute('value')).toBe('0');
});
- it('updates the value on checkboxes from "" to 0', function() {
+ it('updates the value on checkboxes from "" to 0', function () {
ReactDOM.render(
-
,
+
,
container,
);
ReactDOM.render(
-
,
+
,
container,
);
expect(container.firstChild.value).toBe('0');
@@ -533,7 +533,7 @@ describe('ReactDOMInput', () => {
it('should display "foobar" for `defaultValue` of `objToString`', () => {
const objToString = {
- toString: function() {
+ toString: function () {
return 'foobar';
},
};
@@ -680,7 +680,7 @@ describe('ReactDOMInput', () => {
expect(node.value).toBe('foo');
const objToString = {
- toString: function() {
+ toString: function () {
return 'foobar';
},
};
@@ -698,10 +698,10 @@ describe('ReactDOMInput', () => {
let nodeValue = 'a';
const nodeValueSetter = jest.fn();
Object.defineProperty(node, 'value', {
- get: function() {
+ get: function () {
return nodeValue;
},
- set: nodeValueSetter.mockImplementation(function(newValue) {
+ set: nodeValueSetter.mockImplementation(function (newValue) {
nodeValue = newValue;
}),
});
@@ -720,10 +720,10 @@ describe('ReactDOMInput', () => {
let nodeValue = '0';
const nodeValueSetter = jest.fn();
Object.defineProperty(node, 'value', {
- get: function() {
+ get: function () {
return nodeValue;
},
- set: nodeValueSetter.mockImplementation(function(newValue) {
+ set: nodeValueSetter.mockImplementation(function (newValue) {
nodeValue = newValue;
}),
});
@@ -739,10 +739,10 @@ describe('ReactDOMInput', () => {
let nodeValue = 'true';
const nodeValueSetter = jest.fn();
Object.defineProperty(node, 'value', {
- get: function() {
+ get: function () {
return nodeValue;
},
- set: nodeValueSetter.mockImplementation(function(newValue) {
+ set: nodeValueSetter.mockImplementation(function (newValue) {
nodeValue = newValue;
}),
});
@@ -788,7 +788,7 @@ describe('ReactDOMInput', () => {
}
});
- it('should properly transition from an empty value to 0', function() {
+ it('should properly transition from an empty value to 0', function () {
ReactDOM.render(
,
container,
@@ -808,7 +808,7 @@ describe('ReactDOMInput', () => {
}
});
- it('should properly transition from 0 to an empty value', function() {
+ it('should properly transition from 0 to an empty value', function () {
ReactDOM.render(
,
container,
@@ -824,7 +824,7 @@ describe('ReactDOMInput', () => {
expect(node.defaultValue).toBe('');
});
- it('should properly transition a text input from 0 to an empty 0.0', function() {
+ it('should properly transition a text input from 0 to an empty 0.0', function () {
ReactDOM.render(
,
container,
@@ -844,7 +844,7 @@ describe('ReactDOMInput', () => {
}
});
- it('should properly transition a number input from "" to 0', function() {
+ it('should properly transition a number input from "" to 0', function () {
ReactDOM.render(
,
container,
@@ -864,7 +864,7 @@ describe('ReactDOMInput', () => {
}
});
- it('should properly transition a number input from "" to "0"', function() {
+ it('should properly transition a number input from "" to "0"', function () {
ReactDOM.render(
,
container,
@@ -886,7 +886,7 @@ describe('ReactDOMInput', () => {
it('should have the correct target value', () => {
let handled = false;
- const handler = function(event) {
+ const handler = function (event) {
expect(event.target.nodeName).toBe('INPUT');
handled = true;
};
@@ -1286,7 +1286,7 @@ describe('ReactDOMInput', () => {
it('should have a this value of undefined if bind is not used', () => {
expect.assertions(1);
- const unboundInputOnChange = function() {
+ const unboundInputOnChange = function () {
expect(this).toBe(undefined);
};
@@ -1670,21 +1670,21 @@ describe('ReactDOMInput', () => {
it('sets type, step, min, max before value always', () => {
const log = [];
const originalCreateElement = document.createElement;
- spyOnDevAndProd(document, 'createElement').and.callFake(function(type) {
+ spyOnDevAndProd(document, 'createElement').and.callFake(function (type) {
const el = originalCreateElement.apply(this, arguments);
let value = '';
if (type === 'input') {
Object.defineProperty(el, 'value', {
- get: function() {
+ get: function () {
return value;
},
- set: function(val) {
+ set: function (val) {
value = String(val);
log.push('set property value');
},
});
- spyOnDevAndProd(el, 'setAttribute').and.callFake(function(name) {
+ spyOnDevAndProd(el, 'setAttribute').and.callFake(function (name) {
log.push('set attribute ' + name);
});
}
@@ -1743,7 +1743,7 @@ describe('ReactDOMInput', () => {
const log = [];
const originalCreateElement = document.createElement;
- spyOnDevAndProd(document, 'createElement').and.callFake(function(type) {
+ spyOnDevAndProd(document, 'createElement').and.callFake(function (type) {
const el = originalCreateElement.apply(this, arguments);
const getDefaultValue = Object.getOwnPropertyDescriptor(
HTMLInputElement.prototype,
@@ -1763,24 +1763,24 @@ describe('ReactDOMInput', () => {
).set;
if (type === 'input') {
Object.defineProperty(el, 'defaultValue', {
- get: function() {
+ get: function () {
return getDefaultValue.call(this);
},
- set: function(val) {
+ set: function (val) {
log.push(`node.defaultValue = ${strify(val)}`);
setDefaultValue.call(this, val);
},
});
Object.defineProperty(el, 'value', {
- get: function() {
+ get: function () {
return getValue.call(this);
},
- set: function(val) {
+ set: function (val) {
log.push(`node.value = ${strify(val)}`);
setValue.call(this, val);
},
});
- spyOnDevAndProd(el, 'setAttribute').and.callFake(function(name, val) {
+ spyOnDevAndProd(el, 'setAttribute').and.callFake(function (name, val) {
log.push(`node.setAttribute(${strify(name)}, ${strify(val)})`);
});
}
@@ -1808,7 +1808,7 @@ describe('ReactDOMInput', () => {
}
});
- describe('assigning the value attribute on controlled inputs', function() {
+ describe('assigning the value attribute on controlled inputs', function () {
function getTestInput() {
return class extends React.Component {
state = {
@@ -1826,7 +1826,7 @@ describe('ReactDOMInput', () => {
};
}
- it('always sets the attribute when values change on text inputs', function() {
+ it('always sets the attribute when values change on text inputs', function () {
const Input = getTestInput();
const stub = ReactDOM.render(
, container);
const node = ReactDOM.findDOMNode(stub);
@@ -2030,8 +2030,8 @@ describe('ReactDOMInput', () => {
});
});
- describe('When given a Symbol value', function() {
- it('treats initial Symbol value as an empty string', function() {
+ describe('When given a Symbol value', function () {
+ it('treats initial Symbol value as an empty string', function () {
expect(() =>
ReactDOM.render(
{}} />,
@@ -2048,7 +2048,7 @@ describe('ReactDOMInput', () => {
}
});
- it('treats updated Symbol value as an empty string', function() {
+ it('treats updated Symbol value as an empty string', function () {
ReactDOM.render(
{}} />, container);
expect(() =>
ReactDOM.render(
@@ -2066,7 +2066,7 @@ describe('ReactDOMInput', () => {
}
});
- it('treats initial Symbol defaultValue as an empty string', function() {
+ it('treats initial Symbol defaultValue as an empty string', function () {
ReactDOM.render(
, container);
const node = container.firstChild;
@@ -2075,7 +2075,7 @@ describe('ReactDOMInput', () => {
// TODO: we should warn here.
});
- it('treats updated Symbol defaultValue as an empty string', function() {
+ it('treats updated Symbol defaultValue as an empty string', function () {
ReactDOM.render(
, container);
ReactDOM.render(
, container);
const node = container.firstChild;
@@ -2090,8 +2090,8 @@ describe('ReactDOMInput', () => {
});
});
- describe('When given a function value', function() {
- it('treats initial function value as an empty string', function() {
+ describe('When given a function value', function () {
+ it('treats initial function value as an empty string', function () {
expect(() =>
ReactDOM.render(
{}} onChange={() => {}} />,
@@ -2108,7 +2108,7 @@ describe('ReactDOMInput', () => {
}
});
- it('treats updated function value as an empty string', function() {
+ it('treats updated function value as an empty string', function () {
ReactDOM.render(
{}} />, container);
expect(() =>
ReactDOM.render(
@@ -2126,7 +2126,7 @@ describe('ReactDOMInput', () => {
}
});
- it('treats initial function defaultValue as an empty string', function() {
+ it('treats initial function defaultValue as an empty string', function () {
ReactDOM.render(
{}} />, container);
const node = container.firstChild;
@@ -2135,7 +2135,7 @@ describe('ReactDOMInput', () => {
// TODO: we should warn here.
});
- it('treats updated function defaultValue as an empty string', function() {
+ it('treats updated function defaultValue as an empty string', function () {
ReactDOM.render(
, container);
ReactDOM.render(
{}} />, container);
const node = container.firstChild;
@@ -2151,12 +2151,12 @@ describe('ReactDOMInput', () => {
});
});
- describe('checked inputs without a value property', function() {
+ describe('checked inputs without a value property', function () {
// In absence of a value, radio and checkboxes report a value of "on".
// Between 16 and 16.2, we assigned a node's value to it's current
// value in order to "dettach" it from defaultValue. This had the unfortunate
// side-effect of assigning value="on" to radio and checkboxes
- it('does not add "on" in absence of value on a checkbox', function() {
+ it('does not add "on" in absence of value on a checkbox', function () {
ReactDOM.render(
,
container,
@@ -2167,7 +2167,7 @@ describe('ReactDOMInput', () => {
expect(node.hasAttribute('value')).toBe(false);
});
- it('does not add "on" in absence of value on a radio', function() {
+ it('does not add "on" in absence of value on a radio', function () {
ReactDOM.render(
, container);
const node = container.firstChild;
diff --git a/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js b/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js
index 27d0accf04d6f..0cd954a2d8112 100644
--- a/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js
@@ -19,7 +19,7 @@ describe('ReactDOMInvalidARIAHook', () => {
React = require('react');
ReactTestUtils = require('react-dom/test-utils');
- mountComponent = function(props) {
+ mountComponent = function (props) {
ReactTestUtils.renderIntoDocument(
);
};
});
diff --git a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js
index 2ae2d30e8b77c..62273e1133e76 100644
--- a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js
@@ -62,9 +62,7 @@ describe('ReactDOMRoot', () => {
it('warns if a callback parameter is provided to render', () => {
const callback = jest.fn();
const root = ReactDOMClient.createRoot(container);
- expect(() =>
- root.render(
Hi
, callback),
- ).toErrorDev(
+ expect(() => root.render(
Hi
, callback)).toErrorDev(
'render(...): does not support the second callback argument. ' +
'To execute a side effect after rendering, declare it in a component body with useEffect().',
{withoutStack: true},
@@ -108,9 +106,7 @@ describe('ReactDOMRoot', () => {
const callback = jest.fn();
const root = ReactDOMClient.createRoot(container);
root.render(
Hi
);
- expect(() =>
- root.unmount(callback),
- ).toErrorDev(
+ expect(() => root.unmount(callback)).toErrorDev(
'unmount(...): does not support a callback argument. ' +
'To execute a side effect after rendering, declare it in a component body with useEffect().',
{withoutStack: true},
@@ -490,9 +486,7 @@ describe('ReactDOMRoot', () => {
});
it('warn if no children passed to hydrateRoot', async () => {
- expect(() =>
- ReactDOMClient.hydrateRoot(container),
- ).toErrorDev(
+ expect(() => ReactDOMClient.hydrateRoot(container)).toErrorDev(
'Must provide initial children as second argument to hydrateRoot.',
{withoutStack: true},
);
diff --git a/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js b/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js
index 73184e0f4216a..2afdb8b0d353c 100644
--- a/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js
@@ -24,10 +24,10 @@ describe('ReactDOMSafariMicrotaskBug-test', () => {
// In reality, the sync flush happens when an iframe is added to the page.
// https://github.com/facebook/react/issues/22459
let queue = [];
- window.queueMicrotask = function(cb) {
+ window.queueMicrotask = function (cb) {
queue.push(cb);
};
- flushMicrotasksPrematurely = function() {
+ flushMicrotasksPrematurely = function () {
while (queue.length > 0) {
const prevQueue = queue;
queue = [];
diff --git a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js
index 9d943b402da1f..901d20f8c2d83 100644
--- a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js
@@ -15,7 +15,7 @@ describe('ReactDOMSelect', () => {
let ReactDOMServer;
let ReactTestUtils;
- const noop = function() {};
+ const noop = function () {};
beforeEach(() => {
jest.resetModules();
@@ -269,7 +269,7 @@ describe('ReactDOMSelect', () => {
it('should allow setting `value` with `objectToString`', () => {
const objectToString = {
animal: 'giraffe',
- toString: function() {
+ toString: function () {
return this.animal;
},
};
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js
index 42ba08e2a5cb1..33d48026267e4 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js
@@ -33,20 +33,16 @@ function initModules() {
};
}
-const {
- resetModules,
- itRenders,
- clientCleanRender,
- clientRenderOnServerString,
-} = ReactDOMServerIntegrationUtils(initModules);
+const {resetModules, itRenders, clientCleanRender, clientRenderOnServerString} =
+ ReactDOMServerIntegrationUtils(initModules);
describe('ReactDOMServerIntegration', () => {
beforeEach(() => {
resetModules();
});
- describe('property to attribute mapping', function() {
- describe('string properties', function() {
+ describe('property to attribute mapping', function () {
+ describe('string properties', function () {
itRenders('simple numbers', async render => {
const e = await render(
);
expect(e.getAttribute('width')).toBe('30');
@@ -73,7 +69,7 @@ describe('ReactDOMServerIntegration', () => {
});
itRenders('no string prop with function value', async render => {
- const e = await render(
, 1);
+ const e = await render(
, 1);
expect(e.hasAttribute('width')).toBe(false);
});
@@ -83,7 +79,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('boolean properties', function() {
+ describe('boolean properties', function () {
itRenders('boolean prop with true value', async render => {
const e = await render(
);
expect(e.getAttribute('hidden')).toBe('');
@@ -143,7 +139,7 @@ describe('ReactDOMServerIntegration', () => {
});
itRenders('no boolean prop with function value', async render => {
- const e = await render(
, 1);
+ const e = await render(
, 1);
expect(e.hasAttribute('hidden')).toBe(false);
});
@@ -153,7 +149,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('download property (combined boolean/string attribute)', function() {
+ describe('download property (combined boolean/string attribute)', function () {
itRenders('download prop with true value', async render => {
const e = await render(
);
expect(e.getAttribute('download')).toBe('');
@@ -195,7 +191,7 @@ describe('ReactDOMServerIntegration', () => {
});
itRenders('no download prop with function value', async render => {
- const e = await render(
, 1);
+ const e = await render(
, 1);
expect(e.hasAttribute('download')).toBe(false);
});
@@ -205,7 +201,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('className property', function() {
+ describe('className property', function () {
itRenders('className prop with string value', async render => {
const e = await render(
);
expect(e.getAttribute('class')).toBe('myClassName');
@@ -254,7 +250,7 @@ describe('ReactDOMServerIntegration', () => {
);
});
- describe('htmlFor property', function() {
+ describe('htmlFor property', function () {
itRenders('htmlFor with string value', async render => {
const e = await render(
);
expect(e.getAttribute('for')).toBe('myFor');
@@ -287,7 +283,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('numeric properties', function() {
+ describe('numeric properties', function () {
itRenders(
'positive numeric property with positive value',
async render => {
@@ -310,7 +306,7 @@ describe('ReactDOMServerIntegration', () => {
);
itRenders('no numeric prop with function value', async render => {
- const e = await render(
, 1);
+ const e = await render(
, 1);
expect(e.hasAttribute('start')).toBe(false);
});
@@ -322,7 +318,7 @@ describe('ReactDOMServerIntegration', () => {
itRenders(
'no positive numeric prop with function value',
async render => {
- const e = await render(
, 1);
+ const e = await render(
, 1);
expect(e.hasAttribute('size')).toBe(false);
},
);
@@ -333,7 +329,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('props with special meaning in React', function() {
+ describe('props with special meaning in React', function () {
itRenders('no ref attribute', async render => {
class RefComponent extends React.Component {
render() {
@@ -372,7 +368,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('inline styles', function() {
+ describe('inline styles', function () {
itRenders('simple styles', async render => {
const e = await render(
);
expect(e.style.color).toBe('red');
@@ -469,7 +465,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('aria attributes', function() {
+ describe('aria attributes', function () {
itRenders('simple strings', async render => {
const e = await render(
);
expect(e.getAttribute('aria-label')).toBe('hello');
@@ -493,7 +489,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('cased attributes', function() {
+ describe('cased attributes', function () {
itRenders(
'badly cased aliased HTML attribute with a warning',
async render => {
@@ -551,7 +547,7 @@ describe('ReactDOMServerIntegration', () => {
);
});
- describe('unknown attributes', function() {
+ describe('unknown attributes', function () {
itRenders('unknown attributes', async render => {
const e = await render(
);
expect(e.getAttribute('foo')).toBe('bar');
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js
index 97448c461295b..d03701cc00cd4 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js
@@ -41,7 +41,7 @@ describe('ReactDOMServerIntegration', () => {
resetModules();
});
- describe('basic rendering', function() {
+ describe('basic rendering', function () {
itRenders('a blank div', async render => {
const e = await render(
);
expect(e.tagName).toBe('DIV');
@@ -115,10 +115,10 @@ describe('ReactDOMServerIntegration', () => {
itRenders('an iterable', async render => {
const threeDivIterable = {
- '@@iterator': function() {
+ '@@iterator': function () {
let i = 0;
return {
- next: function() {
+ next: function () {
if (i++ < 3) {
return {value:
, done: false};
} else {
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js
index 544d06bb62b56..2dcd232cc48be 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js
@@ -39,7 +39,7 @@ describe('ReactDOMServerIntegration', () => {
resetModules();
});
- describe('class contextType', function() {
+ describe('class contextType', function () {
let PurpleContext, RedContext, Context;
beforeEach(() => {
Context = React.createContext('none');
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js
index 437b719cc1cf1..3ac05bbdbbded 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js
@@ -48,7 +48,7 @@ describe('ReactDOMServerIntegration', () => {
resetModules();
});
- describe('elements and children', function() {
+ describe('elements and children', function () {
function expectNode(node, type, value) {
expect(node).not.toBe(null);
expect(node.nodeType).toBe(type);
@@ -59,7 +59,7 @@ describe('ReactDOMServerIntegration', () => {
expectNode(node, TEXT_NODE_TYPE, text);
}
- describe('text children', function() {
+ describe('text children', function () {
itRenders('a div with text', async render => {
const e = await render(
Text
);
expect(e.tagName).toBe('DIV');
@@ -265,7 +265,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('number children', function() {
+ describe('number children', function () {
itRenders('a number as single child', async render => {
const e = await render(
{3}
);
expect(e.textContent).toBe('3');
@@ -302,7 +302,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('null, false, and undefined children', function() {
+ describe('null, false, and undefined children', function () {
itRenders('null single child as blank', async render => {
const e = await render(
{null}
);
expect(e.childNodes.length).toBe(0);
@@ -365,7 +365,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('elements with implicit namespaces', function() {
+ describe('elements with implicit namespaces', function () {
itRenders('an svg element', async render => {
const e = await render(
);
expect(e.childNodes.length).toBe(0);
@@ -580,7 +580,7 @@ describe('ReactDOMServerIntegration', () => {
}
});
- describe('newline-eating elements', function() {
+ describe('newline-eating elements', function () {
itRenders(
'a newline-eating tag with content not starting with \\n',
async render => {
@@ -601,7 +601,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('different component implementations', function() {
+ describe('different component implementations', function () {
function checkFooDiv(e) {
expect(e.childNodes.length).toBe(1);
expectNode(e.firstChild, TEXT_NODE_TYPE, 'foo');
@@ -627,7 +627,7 @@ describe('ReactDOMServerIntegration', () => {
async render => {
const FactoryComponent = () => {
return {
- render: function() {
+ render: function () {
return
foo
;
},
};
@@ -640,7 +640,7 @@ describe('ReactDOMServerIntegration', () => {
itRenders('factory components', async render => {
const FactoryComponent = () => {
return {
- render: function() {
+ render: function () {
return
foo
;
},
};
@@ -650,7 +650,7 @@ describe('ReactDOMServerIntegration', () => {
}
});
- describe('component hierarchies', function() {
+ describe('component hierarchies', function () {
itRenders('single child hierarchies of components', async render => {
const Component = props =>
{props.children}
;
let e = await render(
@@ -791,7 +791,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('escaping >, <, and &', function() {
+ describe('escaping >, <, and &', function () {
itRenders('>,<, and & as single child', async render => {
const e = await render(
{'Text"'}
);
expect(e.childNodes.length).toBe(1);
@@ -902,7 +902,7 @@ describe('ReactDOMServerIntegration', () => {
);
});
- describe('components that render nullish', function() {
+ describe('components that render nullish', function () {
itRenders('a function returning null', async render => {
const NullComponent = () => null;
await render(
);
@@ -932,7 +932,7 @@ describe('ReactDOMServerIntegration', () => {
});
});
- describe('components that throw errors', function() {
+ describe('components that throw errors', function () {
itThrowsWhenRendering(
'a function returning an object',
async render => {
@@ -976,7 +976,7 @@ describe('ReactDOMServerIntegration', () => {
);
});
- describe('badly-typed elements', function() {
+ describe('badly-typed elements', function () {
itThrowsWhenRendering(
'object',
async render => {
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js
index 48ab3565c6466..b68fc5266bf0e 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js
@@ -72,12 +72,8 @@ function initModules() {
};
}
-const {
- resetModules,
- itRenders,
- itThrowsWhenRendering,
- serverRender,
-} = ReactDOMServerIntegrationUtils(initModules);
+const {resetModules, itRenders, itThrowsWhenRendering, serverRender} =
+ ReactDOMServerIntegrationUtils(initModules);
describe('ReactDOMServerHooks', () => {
beforeEach(() => {
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js
index 01f7327699e57..fb60f0c263fac 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js
@@ -34,18 +34,15 @@ function initModules() {
};
}
-const {
- resetModules,
- itRenders,
- itThrowsWhenRendering,
-} = ReactDOMServerIntegrationUtils(initModules);
+const {resetModules, itRenders, itThrowsWhenRendering} =
+ ReactDOMServerIntegrationUtils(initModules);
describe('ReactDOMServerIntegration', () => {
beforeEach(() => {
resetModules();
});
- describe('legacy context', function() {
+ describe('legacy context', function () {
let PurpleContext, RedContext;
beforeEach(() => {
class Parent extends React.Component {
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js
index ee8a73cd21de3..c90155e8100aa 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js
@@ -39,7 +39,7 @@ describe('ReactDOMServerIntegration', () => {
resetModules();
});
- describe('context', function() {
+ describe('context', function () {
let Context, PurpleContextProvider, RedContextProvider, Consumer;
beforeEach(() => {
Context = React.createContext('none');
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js
index b19926318b42f..a4c7a95598176 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js
@@ -33,18 +33,15 @@ function initModules() {
};
}
-const {
- resetModules,
- expectMarkupMismatch,
- expectMarkupMatch,
-} = ReactDOMServerIntegrationUtils(initModules);
+const {resetModules, expectMarkupMismatch, expectMarkupMatch} =
+ ReactDOMServerIntegrationUtils(initModules);
describe('ReactDOMServerIntegration', () => {
beforeEach(() => {
resetModules();
});
- describe('reconnecting to server markup', function() {
+ describe('reconnecting to server markup', function () {
let EmptyComponent;
beforeEach(() => {
EmptyComponent = class extends React.Component {
@@ -54,8 +51,8 @@ describe('ReactDOMServerIntegration', () => {
};
});
- describe('elements', function() {
- describe('reconnecting different component implementations', function() {
+ describe('elements', function () {
+ describe('reconnecting different component implementations', function () {
let ES6ClassComponent, PureComponent, bareElement;
beforeEach(() => {
// try each type of component on client and server.
@@ -165,7 +162,7 @@ describe('ReactDOMServerIntegration', () => {
));
});
- describe('inline styles', function() {
+ describe('inline styles', function () {
it('should error reconnecting missing style attribute', () =>
expectMarkupMismatch(
,
));
@@ -215,7 +212,7 @@ describe('ReactDOMServerIntegration', () => {
));
});
- describe('text nodes', function() {
+ describe('text nodes', function () {
it('should error reconnecting different text', () =>
expectMarkupMismatch(
Text
,
Other Text
));
@@ -259,7 +256,7 @@ describe('ReactDOMServerIntegration', () => {
));
});
- describe('element trees and children', function() {
+ describe('element trees and children', function () {
it('should error reconnecting missing children', () =>
expectMarkupMismatch(
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js
index 9dc12c71f2f66..67c1a9bf536d2 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js
@@ -44,7 +44,7 @@ describe('ReactDOMServerIntegration', () => {
resetModules();
});
- describe('refs', function() {
+ describe('refs', function () {
it('should not run ref code on server', async () => {
let refCount = 0;
class RefsComponent extends React.Component {
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js
index 23cf020c1b80d..3a01edc364b93 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js
@@ -32,11 +32,8 @@ function initModules() {
};
}
-const {
- resetModules,
- itRenders,
- itThrowsWhenRendering,
-} = ReactDOMServerIntegrationUtils(initModules);
+const {resetModules, itRenders, itThrowsWhenRendering} =
+ ReactDOMServerIntegrationUtils(initModules);
describe('ReactDOMServerIntegrationSelect', () => {
let options;
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js
index ff310de3f6d35..1c9ae5c2737cb 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js
@@ -32,12 +32,8 @@ function initModules() {
};
}
-const {
- resetModules,
- itClientRenders,
- renderIntoDom,
- serverRender,
-} = ReactDOMServerIntegrationUtils(initModules);
+const {resetModules, itClientRenders, renderIntoDom, serverRender} =
+ ReactDOMServerIntegrationUtils(initModules);
describe('ReactDOMServerIntegrationUserInteraction', () => {
let ControlledInput, ControlledTextArea, ControlledCheckbox, ControlledSelect;
@@ -138,7 +134,7 @@ describe('ReactDOMServerIntegrationUserInteraction', () => {
};
});
- describe('user interaction with controlled inputs', function() {
+ describe('user interaction with controlled inputs', function () {
itClientRenders('a controlled text input', async render => {
const setUntrackedValue = Object.getOwnPropertyDescriptor(
HTMLInputElement.prototype,
@@ -248,7 +244,7 @@ describe('ReactDOMServerIntegrationUserInteraction', () => {
});
});
- describe('user interaction with inputs before client render', function() {
+ describe('user interaction with inputs before client render', function () {
// renders the element and changes the value **before** the client
// code has a chance to render; this simulates what happens when a
// user starts to interact with a server-rendered form before
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
index 6da64f9cda992..58c23a05c762d 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
@@ -23,7 +23,7 @@ let IdleEventPriority;
function normalizeCodeLocInfo(strOrErr) {
if (strOrErr && strOrErr.replace) {
- return strOrErr.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function(m, name) {
+ return strOrErr.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function (m, name) {
return '\n in ' + name + ' (at **)';
});
}
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js
index ca795e98d1410..694e56c2aeb23 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js
@@ -138,8 +138,8 @@ describe('ReactDOMServerSelectiveHydration', () => {
Suspense = React.Suspense;
IdleEventPriority = require('react-reconciler/constants').IdleEventPriority;
- ContinuousEventPriority = require('react-reconciler/constants')
- .ContinuousEventPriority;
+ ContinuousEventPriority =
+ require('react-reconciler/constants').ContinuousEventPriority;
});
it('hydrates the target boundary synchronously during a click', async () => {
@@ -1460,7 +1460,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
Scheduler.unstable_yieldValue(text);
return
{text};
}
- const ChildWithBoundary = React.memo(function({text}) {
+ const ChildWithBoundary = React.memo(function ({text}) {
return (
@@ -1904,7 +1904,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
Scheduler.unstable_yieldValue(text);
return {text};
}
- const ChildWithBoundary = React.memo(function({text}) {
+ const ChildWithBoundary = React.memo(function ({text}) {
return (
@@ -1971,7 +1971,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
Scheduler.unstable_yieldValue(text);
return {text};
}
- const ChildWithBoundary = React.memo(function({text}) {
+ const ChildWithBoundary = React.memo(function ({text}) {
return (
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js
index 7779d22866148..97912a4c4690e 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js
@@ -41,11 +41,8 @@ function initModules() {
};
}
-const {
- itThrowsWhenRendering,
- resetModules,
- serverRender,
-} = ReactDOMServerIntegrationUtils(initModules);
+const {itThrowsWhenRendering, resetModules, serverRender} =
+ ReactDOMServerIntegrationUtils(initModules);
describe('ReactDOMServerSuspense', () => {
beforeEach(() => {
diff --git a/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js b/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js
index ca4058f743809..cd7a668246686 100644
--- a/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js
@@ -558,7 +558,7 @@ No matching component was found for:
// Stub out getBoundingClientRect for the specified target.
// This API is required by the test selectors but it isn't implemented by jsdom.
function setBoundingClientRect(target, {x, y, width, height}) {
- target.getBoundingClientRect = function() {
+ target.getBoundingClientRect = function () {
return {
width,
height,
@@ -1134,7 +1134,7 @@ No matching component was found for:
// Stub out getBoundingClientRect for the specified target.
// This API is required by the test selectors but it isn't implemented by jsdom.
function setBoundingClientRect(target, {x, y, width, height}) {
- target.getBoundingClientRect = function() {
+ target.getBoundingClientRect = function () {
return {
width,
height,
diff --git a/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js b/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js
index 870e4e384edcf..7dcb706993803 100644
--- a/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js
@@ -29,7 +29,7 @@ describe('ReactDOMTextarea', () => {
ReactDOMServer = require('react-dom/server');
ReactTestUtils = require('react-dom/test-utils');
- renderTextarea = function(component, container) {
+ renderTextarea = function (component, container) {
if (!container) {
container = document.createElement('div');
}
@@ -74,7 +74,7 @@ describe('ReactDOMTextarea', () => {
it('should display "foobar" for `defaultValue` of `objToString`', () => {
const objToString = {
- toString: function() {
+ toString: function () {
return 'foobar';
},
};
@@ -133,15 +133,15 @@ describe('ReactDOMTextarea', () => {
let counter = 0;
const originalCreateElement = document.createElement;
- spyOnDevAndProd(document, 'createElement').and.callFake(function(type) {
+ spyOnDevAndProd(document, 'createElement').and.callFake(function (type) {
const el = originalCreateElement.apply(this, arguments);
let value = '';
if (type === 'textarea') {
Object.defineProperty(el, 'value', {
- get: function() {
+ get: function () {
return value;
},
- set: function(val) {
+ set: function (val) {
value = String(val);
counter++;
},
@@ -164,7 +164,7 @@ describe('ReactDOMTextarea', () => {
});
it('should render value for SSR', () => {
- const element = ;
+ const element = ;
const markup = ReactDOMServer.renderToString(element);
const div = document.createElement('div');
div.innerHTML = markup;
@@ -208,7 +208,7 @@ describe('ReactDOMTextarea', () => {
expect(node.value).toBe('giraffe');
const objToString = {
- toString: function() {
+ toString: function () {
return 'foo';
},
};
@@ -281,10 +281,10 @@ describe('ReactDOMTextarea', () => {
let nodeValue = 'a';
const nodeValueSetter = jest.fn();
Object.defineProperty(node, 'value', {
- get: function() {
+ get: function () {
return nodeValue;
},
- set: nodeValueSetter.mockImplementation(function(newValue) {
+ set: nodeValueSetter.mockImplementation(function (newValue) {
nodeValue = newValue;
}),
});
@@ -460,7 +460,7 @@ describe('ReactDOMTextarea', () => {
if (ReactFeatureFlags.disableTextareaChildren) {
it('should ignore objects as children', () => {
const obj = {
- toString: function() {
+ toString: function () {
return 'sharkswithlasers';
},
};
@@ -477,7 +477,7 @@ describe('ReactDOMTextarea', () => {
if (!ReactFeatureFlags.disableTextareaChildren) {
it('should allow objects as children', () => {
const obj = {
- toString: function() {
+ toString: function () {
return 'sharkswithlasers';
},
};
diff --git a/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js b/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js
index 1cc318451eb5c..93bc493140501 100644
--- a/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js
+++ b/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js
@@ -53,7 +53,7 @@ describe('ReactEmptyComponent', () => {
}
}
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument();
}).not.toThrowError();
});
@@ -158,10 +158,10 @@ describe('ReactEmptyComponent', () => {
/>
);
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(instance1);
}).not.toThrow();
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(instance2);
}).not.toThrow();
@@ -201,10 +201,10 @@ describe('ReactEmptyComponent', () => {
);
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(instance1);
}).not.toThrow();
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(instance2);
}).not.toThrow();
@@ -308,7 +308,7 @@ describe('ReactEmptyComponent', () => {
}
}
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument();
}).not.toThrow();
});
diff --git a/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js b/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
index 50832b0c2eed3..1ad187b7bedf8 100644
--- a/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
@@ -2460,7 +2460,7 @@ describe('ReactErrorBoundaries', () => {
throw evilError;
};
Object.defineProperty(Throws, 'displayName', {
- get: function() {
+ get: function () {
throw new Error('gotta catch em all');
},
});
diff --git a/packages/react-dom/src/__tests__/ReactErrorLoggingRecovery-test.js b/packages/react-dom/src/__tests__/ReactErrorLoggingRecovery-test.js
index dc15df4d7c9f4..0721e3db4dea4 100644
--- a/packages/react-dom/src/__tests__/ReactErrorLoggingRecovery-test.js
+++ b/packages/react-dom/src/__tests__/ReactErrorLoggingRecovery-test.js
@@ -58,7 +58,7 @@ describe('ReactErrorLoggingRecovery', () => {
console.error = originalConsoleError;
});
- it('should recover from errors in console.error', function() {
+ it('should recover from errors in console.error', function () {
const div = document.createElement('div');
let didCatch = false;
try {
diff --git a/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js b/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js
index 10f53b6962ef3..64dc14248cf27 100644
--- a/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js
+++ b/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js
@@ -102,7 +102,7 @@ describe('ReactFunctionComponent', () => {
function FunctionComponentWithChildContext() {
return null;
}
- FunctionComponentWithChildContext.getDerivedStateFromProps = function() {};
+ FunctionComponentWithChildContext.getDerivedStateFromProps = function () {};
const container = document.createElement('div');
@@ -138,7 +138,7 @@ describe('ReactFunctionComponent', () => {
it('should not throw when stateless component returns undefined', () => {
function NotAComponent() {}
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
@@ -152,7 +152,7 @@ describe('ReactFunctionComponent', () => {
return
;
}
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
);
}).toThrowError(
__DEV__
@@ -323,7 +323,7 @@ describe('ReactFunctionComponent', () => {
};
}
render() {
- return
;
+ return
;
}
}
@@ -401,7 +401,7 @@ describe('ReactFunctionComponent', () => {
});
it('should work with arrow functions', () => {
- let Child = function() {
+ let Child = function () {
return
;
};
// Will create a new bound function without a prototype, much like a native
@@ -412,7 +412,7 @@ describe('ReactFunctionComponent', () => {
});
it('should allow simple functions to return null', () => {
- const Child = function() {
+ const Child = function () {
return null;
};
expect(() => ReactTestUtils.renderIntoDocument(
)).not.toThrow();
diff --git a/packages/react-dom/src/__tests__/ReactIdentity-test.js b/packages/react-dom/src/__tests__/ReactIdentity-test.js
index 06337ccf16ded..9dcfe5a184249 100644
--- a/packages/react-dom/src/__tests__/ReactIdentity-test.js
+++ b/packages/react-dom/src/__tests__/ReactIdentity-test.js
@@ -141,7 +141,7 @@ describe('ReactIdentity', () => {
}
}
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
);
}).not.toThrow();
});
@@ -176,7 +176,7 @@ describe('ReactIdentity', () => {
}
}
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
);
}).not.toThrow();
});
@@ -204,7 +204,7 @@ describe('ReactIdentity', () => {
}
}
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
);
}).not.toThrow();
});
@@ -259,7 +259,7 @@ describe('ReactIdentity', () => {
);
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(component);
}).not.toThrow();
});
diff --git a/packages/react-dom/src/__tests__/ReactMount-test.js b/packages/react-dom/src/__tests__/ReactMount-test.js
index 4cd89816782e1..c69ed03559a66 100644
--- a/packages/react-dom/src/__tests__/ReactMount-test.js
+++ b/packages/react-dom/src/__tests__/ReactMount-test.js
@@ -59,9 +59,7 @@ describe('ReactMount', () => {
}
}
- expect(() =>
- ReactTestUtils.renderIntoDocument(Component),
- ).toErrorDev(
+ expect(() => ReactTestUtils.renderIntoDocument(Component)).toErrorDev(
'Functions are not valid as a React child. ' +
'This may happen if you return a Component instead of from render. ' +
'Or maybe you meant to call this function rather than return it.',
@@ -195,9 +193,7 @@ describe('ReactMount', () => {
// Test that blasting away children throws a warning
const rootNode = container.firstChild;
- expect(() =>
- ReactDOM.render(, rootNode),
- ).toErrorDev(
+ expect(() => ReactDOM.render(, rootNode)).toErrorDev(
'Warning: render(...): Replacing React-rendered children with a new ' +
'root component. If you intended to update the children of this node, ' +
'you should instead have the existing children update their state and ' +
@@ -225,9 +221,7 @@ describe('ReactMount', () => {
// Make sure ReactDOM and ReactDOMOther are different copies
expect(ReactDOM).not.toEqual(ReactDOMOther);
- expect(() =>
- ReactDOMOther.unmountComponentAtNode(container),
- ).toErrorDev(
+ expect(() => ReactDOMOther.unmountComponentAtNode(container)).toErrorDev(
"Warning: unmountComponentAtNode(): The node you're attempting to unmount " +
'was rendered by another copy of React.',
{withoutStack: true},
@@ -241,34 +235,34 @@ describe('ReactMount', () => {
const container = document.createElement('div');
let calls = 0;
- ReactDOM.render(, container, function() {
+ ReactDOM.render(, container, function () {
expect(this.nodeName).toBe('DIV');
calls++;
});
// Update, no type change
- ReactDOM.render(, container, function() {
+ ReactDOM.render(, container, function () {
expect(this.nodeName).toBe('DIV');
calls++;
});
// Update, type change
- ReactDOM.render(, container, function() {
+ ReactDOM.render(, container, function () {
expect(this.nodeName).toBe('SPAN');
calls++;
});
// Batched update, no type change
- ReactDOM.unstable_batchedUpdates(function() {
- ReactDOM.render(, container, function() {
+ ReactDOM.unstable_batchedUpdates(function () {
+ ReactDOM.render(, container, function () {
expect(this.nodeName).toBe('SPAN');
calls++;
});
});
// Batched update, type change
- ReactDOM.unstable_batchedUpdates(function() {
- ReactDOM.render(, container, function() {
+ ReactDOM.unstable_batchedUpdates(function () {
+ ReactDOM.render(, container, function () {
expect(this.nodeName).toBe('ARTICLE');
calls++;
});
diff --git a/packages/react-dom/src/__tests__/ReactMountDestruction-test.js b/packages/react-dom/src/__tests__/ReactMountDestruction-test.js
index 526b7aee2a274..dc04d01578f24 100644
--- a/packages/react-dom/src/__tests__/ReactMountDestruction-test.js
+++ b/packages/react-dom/src/__tests__/ReactMountDestruction-test.js
@@ -50,9 +50,7 @@ describe('ReactMount', () => {
// Test that unmounting at a root node gives a helpful warning
const rootDiv = mainContainerDiv.firstChild;
- expect(() =>
- ReactDOM.unmountComponentAtNode(rootDiv),
- ).toErrorDev(
+ expect(() => ReactDOM.unmountComponentAtNode(rootDiv)).toErrorDev(
"Warning: unmountComponentAtNode(): The node you're attempting to " +
'unmount was rendered by React and is not a top-level container. You ' +
'may have accidentally passed in a React root node instead of its ' +
@@ -75,9 +73,7 @@ describe('ReactMount', () => {
// Test that unmounting at a non-root node gives a different warning
const nonRootDiv = mainContainerDiv.firstChild.firstChild;
- expect(() =>
- ReactDOM.unmountComponentAtNode(nonRootDiv),
- ).toErrorDev(
+ expect(() => ReactDOM.unmountComponentAtNode(nonRootDiv)).toErrorDev(
"Warning: unmountComponentAtNode(): The node you're attempting to " +
'unmount was rendered by React and is not a top-level container. ' +
'Instead, have the parent component update its state and rerender in ' +
diff --git a/packages/react-dom/src/__tests__/ReactMultiChild-test.js b/packages/react-dom/src/__tests__/ReactMultiChild-test.js
index 0685b75612f1f..d33d00275b116 100644
--- a/packages/react-dom/src/__tests__/ReactMultiChild-test.js
+++ b/packages/react-dom/src/__tests__/ReactMultiChild-test.js
@@ -238,7 +238,7 @@ describe('ReactMultiChild', () => {
function createIterable(array) {
return {
- '@@iterator': function() {
+ '@@iterator': function () {
let i = 0;
return {
next() {
@@ -304,8 +304,8 @@ describe('ReactMultiChild', () => {
it('should warn for using generators as children', () => {
function* Foo() {
- yield (Hello
);
- yield (World
);
+ yield Hello
;
+ yield World
;
}
const div = document.createElement('div');
@@ -325,9 +325,9 @@ describe('ReactMultiChild', () => {
it('should not warn for using generators in legacy iterables', () => {
const fooIterable = {
- '@@iterator': function*() {
- yield (Hello
);
- yield (World
);
+ '@@iterator': function* () {
+ yield Hello
;
+ yield World
;
},
};
@@ -345,9 +345,9 @@ describe('ReactMultiChild', () => {
it('should not warn for using generators in modern iterables', () => {
const fooIterable = {
- [Symbol.iterator]: function*() {
- yield (Hello
);
- yield (World
);
+ [Symbol.iterator]: function* () {
+ yield Hello
;
+ yield World
;
},
};
diff --git a/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js b/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js
index 1943281eac954..0bfb27ade197b 100644
--- a/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js
+++ b/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js
@@ -12,7 +12,7 @@
const React = require('react');
const ReactDOM = require('react-dom');
-const stripEmptyValues = function(obj) {
+const stripEmptyValues = function (obj) {
const ret = {};
for (const name in obj) {
if (!obj.hasOwnProperty(name)) {
@@ -254,7 +254,7 @@ function prepareChildrenArray(childrenArray) {
function prepareChildrenLegacyIterable(childrenArray) {
return {
- '@@iterator': function*() {
+ '@@iterator': function* () {
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const child of childrenArray) {
yield child;
@@ -265,7 +265,7 @@ function prepareChildrenLegacyIterable(childrenArray) {
function prepareChildrenModernIterable(childrenArray) {
return {
- [Symbol.iterator]: function*() {
+ [Symbol.iterator]: function* () {
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const child of childrenArray) {
yield child;
diff --git a/packages/react-dom/src/__tests__/ReactMultiChildText-test.js b/packages/react-dom/src/__tests__/ReactMultiChildText-test.js
index b392f3cec9af8..0e4f1c7f9dff8 100644
--- a/packages/react-dom/src/__tests__/ReactMultiChildText-test.js
+++ b/packages/react-dom/src/__tests__/ReactMultiChildText-test.js
@@ -14,7 +14,7 @@ const ReactDOM = require('react-dom');
const ReactTestUtils = require('react-dom/test-utils');
// Helpers
-const testAllPermutations = function(testCases) {
+const testAllPermutations = function (testCases) {
for (let i = 0; i < testCases.length; i += 2) {
const renderWithChildren = testCases[i];
const expectedResultAfterRender = testCases[i + 1];
@@ -33,7 +33,7 @@ const testAllPermutations = function(testCases) {
}
};
-const expectChildren = function(container, children) {
+const expectChildren = function (container, children) {
const outerNode = container.firstChild;
let textNode;
if (typeof children === 'string') {
@@ -171,7 +171,7 @@ describe('ReactMultiChildText', () => {
});
it('should throw if rendering both HTML and children', () => {
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
ghjkl
,
);
@@ -188,7 +188,7 @@ describe('ReactMultiChildText', () => {
,
);
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
A
@@ -196,7 +196,7 @@ describe('ReactMultiChildText', () => {
);
}).not.toThrow();
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
{['A']}
@@ -204,7 +204,7 @@ describe('ReactMultiChildText', () => {
);
}).not.toThrow();
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
{['A', 'B']}
diff --git a/packages/react-dom/src/__tests__/ReactServerRendering-test.js b/packages/react-dom/src/__tests__/ReactServerRendering-test.js
index 4151a38024cad..40c8248ee14c6 100644
--- a/packages/react-dom/src/__tests__/ReactServerRendering-test.js
+++ b/packages/react-dom/src/__tests__/ReactServerRendering-test.js
@@ -613,9 +613,8 @@ describe('ReactDOMServer', () => {
describe('renderToStaticNodeStream', () => {
it('should generate simple markup', () => {
const SuccessfulElement = React.createElement(() =>
);
- const response = ReactDOMServer.renderToStaticNodeStream(
- SuccessfulElement,
- );
+ const response =
+ ReactDOMServer.renderToStaticNodeStream(SuccessfulElement);
expect(response.read().toString()).toMatch(new RegExp('
'));
});
@@ -682,9 +681,7 @@ describe('ReactDOMServer', () => {
}
ReactDOMServer.renderToString(
);
- expect(() =>
- jest.runOnlyPendingTimers(),
- ).toErrorDev(
+ expect(() => jest.runOnlyPendingTimers()).toErrorDev(
'Warning: setState(...): Can only update a mounting component.' +
' This usually means you called setState() outside componentWillMount() on the server.' +
' This is a no-op.\n\nPlease check the code for the Foo component.',
@@ -712,9 +709,7 @@ describe('ReactDOMServer', () => {
}
ReactDOMServer.renderToString(
);
- expect(() =>
- jest.runOnlyPendingTimers(),
- ).toErrorDev(
+ expect(() => jest.runOnlyPendingTimers()).toErrorDev(
'Warning: forceUpdate(...): Can only update a mounting component. ' +
'This usually means you called forceUpdate() outside componentWillMount() on the server. ' +
'This is a no-op.\n\nPlease check the code for the Baz component.',
diff --git a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js
index 029c5cc6e2c7f..381cd9b0ebfc9 100644
--- a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js
+++ b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js
@@ -581,18 +581,18 @@ describe('ReactDOMServerHydration', () => {
// Install setters to activate `in` check
Object.defineProperty(customElement, 'str', {
- set: function(x) {
+ set: function (x) {
this._str = x;
},
- get: function() {
+ get: function () {
return this._str;
},
});
Object.defineProperty(customElement, 'obj', {
- set: function(x) {
+ set: function (x) {
this._obj = x;
},
- get: function() {
+ get: function () {
return this._obj;
},
});
diff --git a/packages/react-dom/src/__tests__/ReactTestUtils-test.js b/packages/react-dom/src/__tests__/ReactTestUtils-test.js
index cba5783886cdf..e993b14190a19 100644
--- a/packages/react-dom/src/__tests__/ReactTestUtils-test.js
+++ b/packages/react-dom/src/__tests__/ReactTestUtils-test.js
@@ -40,9 +40,7 @@ describe('ReactTestUtils', () => {
MockedComponent.prototype.render = jest.fn();
// Patch it up so it returns its children.
- expect(() =>
- ReactTestUtils.mockComponent(MockedComponent),
- ).toWarnDev(
+ expect(() => ReactTestUtils.mockComponent(MockedComponent)).toWarnDev(
'ReactTestUtils.mockComponent() is deprecated. ' +
'Use shallow rendering or jest.mock() instead.\n\n' +
'See https://reactjs.org/link/test-utils-mock-component for more information.',
@@ -188,7 +186,7 @@ describe('ReactTestUtils', () => {
);
const log = [];
- ReactTestUtils.findAllInRenderedTree(tree, function(child) {
+ ReactTestUtils.findAllInRenderedTree(tree, function (child) {
if (ReactTestUtils.isDOMComponent(child)) {
log.push(ReactDOM.findDOMNode(child).textContent);
}
@@ -210,7 +208,7 @@ describe('ReactTestUtils', () => {
'textarea',
];
- injectedDOMComponents.forEach(function(type) {
+ injectedDOMComponents.forEach(function (type) {
const testComponent = ReactTestUtils.renderIntoDocument(
React.createElement(type),
);
@@ -331,7 +329,7 @@ describe('ReactTestUtils', () => {
describe('Simulate', () => {
it('should change the value of an input field', () => {
const obj = {
- handler: function(e) {
+ handler: function (e) {
e.persist();
},
};
@@ -367,7 +365,7 @@ describe('ReactTestUtils', () => {
}
const obj = {
- handler: function(e) {
+ handler: function (e) {
e.persist();
},
};
diff --git a/packages/react-dom/src/__tests__/ReactUpdates-test.js b/packages/react-dom/src/__tests__/ReactUpdates-test.js
index 7ac8438691afd..af5dff0155fc1 100644
--- a/packages/react-dom/src/__tests__/ReactUpdates-test.js
+++ b/packages/react-dom/src/__tests__/ReactUpdates-test.js
@@ -58,7 +58,7 @@ describe('ReactUpdates', () => {
const instance = ReactTestUtils.renderIntoDocument(
);
expect(instance.state.x).toBe(0);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
instance.setState({x: 1});
instance.setState({x: 2});
expect(instance.state.x).toBe(0);
@@ -92,7 +92,7 @@ describe('ReactUpdates', () => {
expect(instance.state.x).toBe(0);
expect(instance.state.y).toBe(0);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
instance.setState({x: 1});
instance.setState({y: 2});
expect(instance.state.x).toBe(0);
@@ -129,7 +129,7 @@ describe('ReactUpdates', () => {
expect(instance.props.x).toBe(0);
expect(instance.state.y).toBe(0);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
ReactDOM.render(
, container);
instance.setState({y: 2});
expect(instance.props.x).toBe(0);
@@ -181,7 +181,7 @@ describe('ReactUpdates', () => {
expect(instance.state.x).toBe(0);
expect(child.state.y).toBe(0);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
instance.setState({x: 1});
child.setState({y: 2});
expect(instance.state.x).toBe(0);
@@ -235,7 +235,7 @@ describe('ReactUpdates', () => {
expect(instance.state.x).toBe(0);
expect(child.state.y).toBe(0);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
child.setState({y: 2});
instance.setState({x: 1});
expect(instance.state.x).toBe(0);
@@ -271,9 +271,9 @@ describe('ReactUpdates', () => {
expect(instance.state.x).toBe(0);
let innerCallbackRun = false;
- ReactDOM.unstable_batchedUpdates(function() {
- instance.setState({x: 1}, function() {
- instance.setState({x: 2}, function() {
+ ReactDOM.unstable_batchedUpdates(function () {
+ instance.setState({x: 1}, function () {
+ instance.setState({x: 2}, function () {
expect(this).toBe(instance);
innerCallbackRun = true;
expect(instance.state.x).toBe(2);
@@ -315,11 +315,11 @@ describe('ReactUpdates', () => {
expect(instance.state.x).toBe(0);
let callbacksRun = 0;
- ReactDOM.unstable_batchedUpdates(function() {
- instance.setState({x: 1}, function() {
+ ReactDOM.unstable_batchedUpdates(function () {
+ instance.setState({x: 1}, function () {
callbacksRun++;
});
- instance.forceUpdate(function() {
+ instance.forceUpdate(function () {
callbacksRun++;
});
expect(instance.state.x).toBe(0);
@@ -366,14 +366,14 @@ describe('ReactUpdates', () => {
expect(parentRenderCount).toBe(1);
expect(childRenderCount).toBe(1);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
instance.setState({x: 1});
});
expect(parentRenderCount).toBe(1);
expect(childRenderCount).toBe(1);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
instance.childRef.current.setState({x: 1});
});
@@ -423,10 +423,10 @@ describe('ReactUpdates', () => {
let didUpdates = [];
const UpdateLoggingMixin = {
- UNSAFE_componentWillUpdate: function() {
+ UNSAFE_componentWillUpdate: function () {
willUpdates.push(this.constructor.displayName);
},
- componentDidUpdate: function() {
+ componentDidUpdate: function () {
didUpdates.push(this.constructor.displayName);
},
};
@@ -507,7 +507,7 @@ describe('ReactUpdates', () => {
function testUpdates(components, desiredWillUpdates, desiredDidUpdates) {
let i;
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
for (i = 0; i < components.length; i++) {
triggerUpdate(components[i]);
}
@@ -517,7 +517,7 @@ describe('ReactUpdates', () => {
// Try them in reverse order
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
for (i = components.length - 1; i >= 0; i--) {
triggerUpdate(components[i]);
}
@@ -588,7 +588,7 @@ describe('ReactUpdates', () => {
}
const a = ReactTestUtils.renderIntoDocument(
);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
a.setState({x: 1});
b.setState({x: 1});
});
@@ -616,7 +616,7 @@ describe('ReactUpdates', () => {
const x = this.state.x;
updates.push('Outer-didUpdate-' + x);
updates.push('Inner-setState-' + x);
- this.innerRef.current.setState({x: x}, function() {
+ this.innerRef.current.setState({x: x}, function () {
updates.push('Inner-callback-' + x);
});
}
@@ -638,10 +638,10 @@ describe('ReactUpdates', () => {
const instance = ReactTestUtils.renderIntoDocument(
);
updates.push('Outer-setState-1');
- instance.setState({x: 1}, function() {
+ instance.setState({x: 1}, function () {
updates.push('Outer-callback-1');
updates.push('Outer-setState-2');
- instance.setState({x: 2}, function() {
+ instance.setState({x: 2}, function () {
updates.push('Outer-callback-2');
});
});
@@ -706,9 +706,9 @@ describe('ReactUpdates', () => {
expect(updates).toEqual([0, 1, 2]);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
// Simulate update on each component from top to bottom.
- instances.forEach(function(instance) {
+ instances.forEach(function (instance) {
instance.forceUpdate();
});
});
@@ -795,7 +795,7 @@ describe('ReactUpdates', () => {
}
}
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
ReactTestUtils.renderIntoDocument(
@@ -816,7 +816,7 @@ describe('ReactUpdates', () => {
UNSAFE_componentWillReceiveProps(nextProps) {
const newX = nextProps.x;
- this.setState({x: newX}, function() {
+ this.setState({x: newX}, function () {
// State should have updated by the time this callback gets called
expect(this.state.x).toBe(newX);
callbackCount++;
@@ -861,7 +861,7 @@ describe('ReactUpdates', () => {
const component = ReactTestUtils.renderIntoDocument(
);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
// B will have scheduled an update but the batching should ensure that its
// update never fires.
componentB.setState({updates: 1});
@@ -1003,7 +1003,7 @@ describe('ReactUpdates', () => {
const parent = ReactTestUtils.renderIntoDocument(
);
const child = parent.getChild();
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
parent.forceUpdate();
child.forceUpdate();
});
@@ -1052,7 +1052,7 @@ describe('ReactUpdates', () => {
callbacks = callbacks.filter(c => c !== this.onChange);
}
render() {
- return
;
+ return
;
}
}
@@ -1060,7 +1060,7 @@ describe('ReactUpdates', () => {
});
it('unstable_batchedUpdates should return value from a callback', () => {
- const result = ReactDOM.unstable_batchedUpdates(function() {
+ const result = ReactDOM.unstable_batchedUpdates(function () {
return 42;
});
expect(result).toEqual(42);
@@ -1069,7 +1069,7 @@ describe('ReactUpdates', () => {
it('unmounts and remounts a root in the same batch', () => {
const container = document.createElement('div');
ReactDOM.render(
a, container);
- ReactDOM.unstable_batchedUpdates(function() {
+ ReactDOM.unstable_batchedUpdates(function () {
ReactDOM.unmountComponentAtNode(container);
ReactDOM.render(
b, container);
});
diff --git a/packages/react-dom/src/__tests__/findDOMNode-test.js b/packages/react-dom/src/__tests__/findDOMNode-test.js
index 356d42e26c779..59f819462421c 100644
--- a/packages/react-dom/src/__tests__/findDOMNode-test.js
+++ b/packages/react-dom/src/__tests__/findDOMNode-test.js
@@ -64,7 +64,7 @@ describe('findDOMNode', () => {
});
it('findDOMNode should reject random objects', () => {
- expect(function() {
+ expect(function () {
ReactDOM.findDOMNode({foo: 'bar'});
}).toThrowError('Argument appears to not be a ReactComponent. Keys: foo');
});
diff --git a/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js b/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js
index 20578784ce29d..902e3c155c3ca 100644
--- a/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js
+++ b/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js
@@ -51,7 +51,7 @@ describe('quoteAttributeValueForBrowser', () => {
it('object is passed to a string inside attributes', () => {
const sampleObject = {
- toString: function() {
+ toString: function () {
return 'ponys';
},
};
diff --git a/packages/react-dom/src/__tests__/refs-destruction-test.js b/packages/react-dom/src/__tests__/refs-destruction-test.js
index aaa1fe1ab72b9..d8a3e750b8fd2 100644
--- a/packages/react-dom/src/__tests__/refs-destruction-test.js
+++ b/packages/react-dom/src/__tests__/refs-destruction-test.js
@@ -114,8 +114,8 @@ describe('refs-destruction', () => {
componentWillUnmount() {
const self = this;
// some async animation
- setTimeout(function() {
- expect(function() {
+ setTimeout(function () {
+ expect(function () {
ReactDOM.unmountComponentAtNode(self.div);
}).not.toThrow();
document.body.removeChild(self.div);
diff --git a/packages/react-dom/src/__tests__/refs-test.js b/packages/react-dom/src/__tests__/refs-test.js
index a8af8cfd66e84..355ce3d18c93e 100644
--- a/packages/react-dom/src/__tests__/refs-test.js
+++ b/packages/react-dom/src/__tests__/refs-test.js
@@ -70,7 +70,7 @@ describe('reactiverefs', () => {
}
}
- const expectClickLogsLengthToBe = function(instance, length) {
+ const expectClickLogsLengthToBe = function (instance, length) {
const clickLogs = ReactTestUtils.scryRenderedDOMComponentsWithClass(
instance,
'clickLogDiv',
@@ -82,7 +82,7 @@ describe('reactiverefs', () => {
/**
* Render a TestRefsComponent and ensure that the main refs are wired up.
*/
- const renderTestRefsComponent = function() {
+ const renderTestRefsComponent = function () {
/**
* Only purpose is to test that refs are tracked even when applied to a
* component that is injected down several layers. Ref systems are difficult to
@@ -492,7 +492,7 @@ describe('creating element with string ref in constructor', () => {
it('throws an error', () => {
ReactTestUtils = require('react-dom/test-utils');
- expect(function() {
+ expect(function () {
ReactTestUtils.renderIntoDocument(
);
}).toThrowError(
'Element ref was specified as a string (p) but no owner was set. This could happen for one of' +
diff --git a/packages/react-dom/src/__tests__/renderSubtreeIntoContainer-test.js b/packages/react-dom/src/__tests__/renderSubtreeIntoContainer-test.js
index b54e6851512b9..288a72818e6bb 100644
--- a/packages/react-dom/src/__tests__/renderSubtreeIntoContainer-test.js
+++ b/packages/react-dom/src/__tests__/renderSubtreeIntoContainer-test.js
@@ -13,8 +13,8 @@ const React = require('react');
const PropTypes = require('prop-types');
const ReactDOM = require('react-dom');
const ReactTestUtils = require('react-dom/test-utils');
-const renderSubtreeIntoContainer = require('react-dom')
- .unstable_renderSubtreeIntoContainer;
+const renderSubtreeIntoContainer =
+ require('react-dom').unstable_renderSubtreeIntoContainer;
describe('renderSubtreeIntoContainer', () => {
it('should pass context when rendering subtree elsewhere', () => {
@@ -47,7 +47,7 @@ describe('renderSubtreeIntoContainer', () => {
componentDidMount() {
expect(
- function() {
+ function () {
renderSubtreeIntoContainer(this,
, portal);
}.bind(this),
).toErrorDev(
@@ -92,7 +92,7 @@ describe('renderSubtreeIntoContainer', () => {
}
componentDidMount() {
- expect(function() {
+ expect(function () {
renderSubtreeIntoContainer(
,
, portal);
}).toThrowError('parentComponentmust be a valid React Component');
}
diff --git a/packages/react-dom/src/__tests__/utils/ReactDOMServerIntegrationTestUtils.js b/packages/react-dom/src/__tests__/utils/ReactDOMServerIntegrationTestUtils.js
index e3a6331c99331..f4d321ffc1319 100644
--- a/packages/react-dom/src/__tests__/utils/ReactDOMServerIntegrationTestUtils.js
+++ b/packages/react-dom/src/__tests__/utils/ReactDOMServerIntegrationTestUtils.js
@@ -12,7 +12,7 @@
const stream = require('stream');
const shouldIgnoreConsoleError = require('../../../../../scripts/jest/shouldIgnoreConsoleError');
-module.exports = function(initModules) {
+module.exports = function (initModules) {
let ReactDOM;
let ReactDOMServer;
let act;
@@ -241,8 +241,10 @@ module.exports = function(initModules) {
if (shouldUseDocument(element)) {
// We can't render into a document during a clean render,
// so instead, we'll render the children into the document element.
- cleanContainer = getContainerFromMarkup(element, '')
- .documentElement;
+ cleanContainer = getContainerFromMarkup(
+ element,
+ '',
+ ).documentElement;
element = element.props.children;
} else {
cleanContainer = document.createElement('div');
diff --git a/packages/react-dom/src/client/ReactDOMLegacy.js b/packages/react-dom/src/client/ReactDOMLegacy.js
index 39e00ffc89a68..b1f06e6e15dbe 100644
--- a/packages/react-dom/src/client/ReactDOMLegacy.js
+++ b/packages/react-dom/src/client/ReactDOMLegacy.js
@@ -121,7 +121,7 @@ function legacyCreateRootFromDOMContainer(
if (isHydrationContainer) {
if (typeof callback === 'function') {
const originalCallback = callback;
- callback = function() {
+ callback = function () {
const instance = getPublicRootInstance(root);
originalCallback.call(instance);
};
@@ -159,7 +159,7 @@ function legacyCreateRootFromDOMContainer(
if (typeof callback === 'function') {
const originalCallback = callback;
- callback = function() {
+ callback = function () {
const instance = getPublicRootInstance(root);
originalCallback.call(instance);
};
@@ -232,7 +232,7 @@ function legacyRenderSubtreeIntoContainer(
root = maybeRoot;
if (typeof callback === 'function') {
const originalCallback = callback;
- callback = function() {
+ callback = function () {
const instance = getPublicRootInstance(root);
originalCallback.call(instance);
};
diff --git a/packages/react-dom/src/client/ReactDOMRoot.js b/packages/react-dom/src/client/ReactDOMRoot.js
index 12f62e2f1c0b6..08b849f21fcce 100644
--- a/packages/react-dom/src/client/ReactDOMRoot.js
+++ b/packages/react-dom/src/client/ReactDOMRoot.js
@@ -97,86 +97,86 @@ function ReactDOMRoot(internalRoot: FiberRoot) {
}
// $FlowFixMe[prop-missing] found when upgrading Flow
-// $FlowFixMe[missing-this-annot]
-ReactDOMHydrationRoot.prototype.render = ReactDOMRoot.prototype.render = function(
- children: ReactNodeList,
-): void {
- const root = this._internalRoot;
- if (root === null) {
- throw new Error('Cannot update an unmounted root.');
- }
-
- if (__DEV__) {
- if (typeof arguments[1] === 'function') {
- console.error(
- 'render(...): does not support the second callback argument. ' +
- 'To execute a side effect after rendering, declare it in a component body with useEffect().',
- );
- } else if (isValidContainer(arguments[1])) {
- console.error(
- 'You passed a container to the second argument of root.render(...). ' +
- "You don't need to pass it again since you already passed it to create the root.",
- );
- } else if (typeof arguments[1] !== 'undefined') {
- console.error(
- 'You passed a second argument to root.render(...) but it only accepts ' +
- 'one argument.',
- );
+ReactDOMHydrationRoot.prototype.render = ReactDOMRoot.prototype.render =
+ // $FlowFixMe[missing-this-annot]
+ function (children: ReactNodeList): void {
+ const root = this._internalRoot;
+ if (root === null) {
+ throw new Error('Cannot update an unmounted root.');
}
- const container = root.containerInfo;
+ if (__DEV__) {
+ if (typeof arguments[1] === 'function') {
+ console.error(
+ 'render(...): does not support the second callback argument. ' +
+ 'To execute a side effect after rendering, declare it in a component body with useEffect().',
+ );
+ } else if (isValidContainer(arguments[1])) {
+ console.error(
+ 'You passed a container to the second argument of root.render(...). ' +
+ "You don't need to pass it again since you already passed it to create the root.",
+ );
+ } else if (typeof arguments[1] !== 'undefined') {
+ console.error(
+ 'You passed a second argument to root.render(...) but it only accepts ' +
+ 'one argument.',
+ );
+ }
- if (
- !enableFloat &&
- !enableHostSingletons &&
- container.nodeType !== COMMENT_NODE
- ) {
- const hostInstance = findHostInstanceWithNoPortals(root.current);
- if (hostInstance) {
- if (hostInstance.parentNode !== container) {
- console.error(
- 'render(...): It looks like the React-rendered content of the ' +
- 'root container was removed without using React. This is not ' +
- 'supported and will cause errors. Instead, call ' +
- "root.unmount() to empty a root's container.",
- );
+ const container = root.containerInfo;
+
+ if (
+ !enableFloat &&
+ !enableHostSingletons &&
+ container.nodeType !== COMMENT_NODE
+ ) {
+ const hostInstance = findHostInstanceWithNoPortals(root.current);
+ if (hostInstance) {
+ if (hostInstance.parentNode !== container) {
+ console.error(
+ 'render(...): It looks like the React-rendered content of the ' +
+ 'root container was removed without using React. This is not ' +
+ 'supported and will cause errors. Instead, call ' +
+ "root.unmount() to empty a root's container.",
+ );
+ }
}
}
}
- }
- updateContainer(children, root, null, null);
-};
+ updateContainer(children, root, null, null);
+ };
// $FlowFixMe[prop-missing] found when upgrading Flow
-// $FlowFixMe[missing-this-annot]
-ReactDOMHydrationRoot.prototype.unmount = ReactDOMRoot.prototype.unmount = function(): void {
- if (__DEV__) {
- if (typeof arguments[0] === 'function') {
- console.error(
- 'unmount(...): does not support a callback argument. ' +
- 'To execute a side effect after rendering, declare it in a component body with useEffect().',
- );
- }
- }
- const root = this._internalRoot;
- if (root !== null) {
- this._internalRoot = null;
- const container = root.containerInfo;
+ReactDOMHydrationRoot.prototype.unmount = ReactDOMRoot.prototype.unmount =
+ // $FlowFixMe[missing-this-annot]
+ function (): void {
if (__DEV__) {
- if (isAlreadyRendering()) {
+ if (typeof arguments[0] === 'function') {
console.error(
- 'Attempted to synchronously unmount a root while React was already ' +
- 'rendering. React cannot finish unmounting the root until the ' +
- 'current render has completed, which may lead to a race condition.',
+ 'unmount(...): does not support a callback argument. ' +
+ 'To execute a side effect after rendering, declare it in a component body with useEffect().',
);
}
}
- flushSync(() => {
- updateContainer(null, root, null, null);
- });
- unmarkContainerAsRoot(container);
- }
-};
+ const root = this._internalRoot;
+ if (root !== null) {
+ this._internalRoot = null;
+ const container = root.containerInfo;
+ if (__DEV__) {
+ if (isAlreadyRendering()) {
+ console.error(
+ 'Attempted to synchronously unmount a root while React was already ' +
+ 'rendering. React cannot finish unmounting the root until the ' +
+ 'current render has completed, which may lead to a race condition.',
+ );
+ }
+ }
+ flushSync(() => {
+ updateContainer(null, root, null, null);
+ });
+ unmarkContainerAsRoot(container);
+ }
+ };
export function createRoot(
container: Element | Document | DocumentFragment,
diff --git a/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js b/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js
index ad282ef6d557a..7835965ed7432 100644
--- a/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js
+++ b/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js
@@ -10,8 +10,8 @@
'use strict';
// TODO: can we express this test with only public API?
-const getNodeForCharacterOffset = require('react-dom-bindings/src/client/getNodeForCharacterOffset')
- .default;
+const getNodeForCharacterOffset =
+ require('react-dom-bindings/src/client/getNodeForCharacterOffset').default;
// Create node from HTML string
function createNode(html) {
diff --git a/packages/react-dom/src/client/__tests__/trustedTypes-test.internal.js b/packages/react-dom/src/client/__tests__/trustedTypes-test.internal.js
index e115027d8dc71..7483d15e7fcce 100644
--- a/packages/react-dom/src/client/__tests__/trustedTypes-test.internal.js
+++ b/packages/react-dom/src/client/__tests__/trustedTypes-test.internal.js
@@ -22,7 +22,7 @@ describe('when Trusted Types are available in global object', () => {
container = document.createElement('div');
const fakeTTObjects = new Set();
window.trustedTypes = {
- isHTML: function(value) {
+ isHTML: function (value) {
if (this !== window.trustedTypes) {
throw new Error(this);
}
@@ -100,7 +100,7 @@ describe('when Trusted Types are available in global object', () => {
const setAttribute = Element.prototype.setAttribute;
try {
const setAttributeCalls = [];
- Element.prototype.setAttribute = function(name, value) {
+ Element.prototype.setAttribute = function (name, value) {
setAttributeCalls.push([this, name.toLowerCase(), value]);
return setAttribute.apply(this, arguments);
};
@@ -128,7 +128,7 @@ describe('when Trusted Types are available in global object', () => {
const setAttribute = Element.prototype.setAttribute;
try {
const setAttributeCalls = [];
- Element.prototype.setAttribute = function(name, value) {
+ Element.prototype.setAttribute = function (name, value) {
setAttributeCalls.push([this, name.toLowerCase(), value]);
return setAttribute.apply(this, arguments);
};
@@ -156,7 +156,7 @@ describe('when Trusted Types are available in global object', () => {
const setAttributeNS = Element.prototype.setAttributeNS;
try {
const setAttributeNSCalls = [];
- Element.prototype.setAttributeNS = function(ns, name, value) {
+ Element.prototype.setAttributeNS = function (ns, name, value) {
setAttributeNSCalls.push([this, ns, name, value]);
return setAttributeNS.apply(this, arguments);
};
diff --git a/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js b/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js
index ed8323161b39f..3cad26f326e1b 100644
--- a/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js
+++ b/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js
@@ -33,12 +33,12 @@ const eventListenersToClear = [];
function startNativeEventListenerClearDown() {
const nativeWindowEventListener = window.addEventListener;
- window.addEventListener = function(...params) {
+ window.addEventListener = function (...params) {
eventListenersToClear.push({target: window, params});
return nativeWindowEventListener.apply(this, params);
};
const nativeDocumentEventListener = document.addEventListener;
- document.addEventListener = function(...params) {
+ document.addEventListener = function (...params) {
eventListenersToClear.push({target: document, params});
return nativeDocumentEventListener.apply(this, params);
};
@@ -2352,12 +2352,10 @@ describe('DOMPluginEventSystem', () => {
const onBeforeBlur = jest.fn(e => log.push(e.type));
const innerRef = React.createRef();
const innerRef2 = React.createRef();
- const setAfterBlurHandle = ReactDOM.unstable_createEventHandle(
- 'afterblur',
- );
- const setBeforeBlurHandle = ReactDOM.unstable_createEventHandle(
- 'beforeblur',
- );
+ const setAfterBlurHandle =
+ ReactDOM.unstable_createEventHandle('afterblur');
+ const setBeforeBlurHandle =
+ ReactDOM.unstable_createEventHandle('beforeblur');
const Component = ({show}) => {
const ref = React.useRef(null);
@@ -2411,12 +2409,10 @@ describe('DOMPluginEventSystem', () => {
const onBeforeBlur = jest.fn(e => log.push(e.type));
const innerRef = React.createRef();
const innerRef2 = React.createRef();
- const setAfterBlurHandle = ReactDOM.unstable_createEventHandle(
- 'afterblur',
- );
- const setBeforeBlurHandle = ReactDOM.unstable_createEventHandle(
- 'beforeblur',
- );
+ const setAfterBlurHandle =
+ ReactDOM.unstable_createEventHandle('afterblur');
+ const setBeforeBlurHandle =
+ ReactDOM.unstable_createEventHandle('beforeblur');
const Component = ({show}) => {
const ref = React.useRef(null);
@@ -2468,9 +2464,8 @@ describe('DOMPluginEventSystem', () => {
const onBeforeBlur = jest.fn();
const innerRef = React.createRef();
const innerRef2 = React.createRef();
- const setBeforeBlurHandle = ReactDOM.unstable_createEventHandle(
- 'beforeblur',
- );
+ const setBeforeBlurHandle =
+ ReactDOM.unstable_createEventHandle('beforeblur');
const ref2 = React.createRef();
const Component = ({show}) => {
@@ -2533,12 +2528,10 @@ describe('DOMPluginEventSystem', () => {
const promise = new Promise(
resolvePromise => (resolve = resolvePromise),
);
- const setAfterBlurHandle = ReactDOM.unstable_createEventHandle(
- 'afterblur',
- );
- const setBeforeBlurHandle = ReactDOM.unstable_createEventHandle(
- 'beforeblur',
- );
+ const setAfterBlurHandle =
+ ReactDOM.unstable_createEventHandle('afterblur');
+ const setBeforeBlurHandle =
+ ReactDOM.unstable_createEventHandle('beforeblur');
function Child() {
if (suspend) {
@@ -2608,9 +2601,8 @@ describe('DOMPluginEventSystem', () => {
const onBeforeBlur = jest.fn();
const innerRef = React.createRef();
const innerRef2 = React.createRef();
- const setBeforeBlurHandle = ReactDOM.unstable_createEventHandle(
- 'beforeblur',
- );
+ const setBeforeBlurHandle =
+ ReactDOM.unstable_createEventHandle('beforeblur');
const ref2 = React.createRef();
const Suspense = React.Suspense;
let suspend = false;
@@ -2689,9 +2681,8 @@ describe('DOMPluginEventSystem', () => {
const Suspense = React.Suspense;
let suspend = false;
const promise = Promise.resolve();
- const setBeforeBlurHandle = ReactDOM.unstable_createEventHandle(
- 'beforeblur',
- );
+ const setBeforeBlurHandle =
+ ReactDOM.unstable_createEventHandle('beforeblur');
const innerRef = React.createRef();
function Child() {
@@ -3208,12 +3199,10 @@ describe('DOMPluginEventSystem', () => {
container.addEventListener('wheel', handler);
const ref = React.createRef();
- const setTouchStart = ReactDOM.unstable_createEventHandle(
- 'touchstart',
- );
- const setTouchMove = ReactDOM.unstable_createEventHandle(
- 'touchmove',
- );
+ const setTouchStart =
+ ReactDOM.unstable_createEventHandle('touchstart');
+ const setTouchMove =
+ ReactDOM.unstable_createEventHandle('touchmove');
const setWheel = ReactDOM.unstable_createEventHandle('wheel');
function Component() {
diff --git a/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js b/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js
index 1d7d7c53236ae..51fb21b696415 100644
--- a/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js
+++ b/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js
@@ -42,14 +42,14 @@ describe('ChangeEventPlugin', () => {
// - calling 'window.postMessage' should actually fire postmessage handlers
const originalAddEventListener = global.addEventListener;
let postMessageCallback;
- global.addEventListener = function(eventName, callback, useCapture) {
+ global.addEventListener = function (eventName, callback, useCapture) {
if (eventName === 'message') {
postMessageCallback = callback;
} else {
originalAddEventListener(eventName, callback, useCapture);
}
};
- global.postMessage = function(messageKey, targetOrigin) {
+ global.postMessage = function (messageKey, targetOrigin) {
const postMessageEvent = {source: window, data: messageKey};
if (postMessageCallback) {
postMessageCallback(postMessageEvent);
@@ -472,7 +472,7 @@ describe('ChangeEventPlugin', () => {
// https://github.com/facebook/react/issues/10196
try {
originalCreateElement = document.createElement;
- document.createElement = function() {
+ document.createElement = function () {
const node = originalCreateElement.apply(this, arguments);
Object.defineProperty(node, 'value', {
get() {},
diff --git a/packages/react-dom/src/events/plugins/__tests__/SelectEventPlugin-test.js b/packages/react-dom/src/events/plugins/__tests__/SelectEventPlugin-test.js
index 5eada97ab45b4..b21b5e34552ed 100644
--- a/packages/react-dom/src/events/plugins/__tests__/SelectEventPlugin-test.js
+++ b/packages/react-dom/src/events/plugins/__tests__/SelectEventPlugin-test.js
@@ -40,7 +40,7 @@ describe('SelectEventPlugin', () => {
// Pass `onMouseDown` so React registers a top-level listener.
const node = ReactDOM.render(
-
,
+
,
container,
);
@@ -177,7 +177,7 @@ describe('SelectEventPlugin', () => {
expect(select).toHaveBeenCalledTimes(1);
});
- it('should handle selectionchange events', function() {
+ it('should handle selectionchange events', function () {
const onSelect = jest.fn();
const node = ReactDOM.render(
,
diff --git a/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js b/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js
index b3e70a45195ed..005ccfc0acd35 100644
--- a/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js
+++ b/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js
@@ -9,7 +9,7 @@
'use strict';
-describe('SimpleEventPlugin', function() {
+describe('SimpleEventPlugin', function () {
let React;
let ReactDOM;
let ReactDOMClient;
@@ -36,7 +36,7 @@ describe('SimpleEventPlugin', function() {
return element;
}
- beforeEach(function() {
+ beforeEach(function () {
jest.resetModules();
React = require('react');
ReactDOM = require('react-dom');
@@ -53,12 +53,12 @@ describe('SimpleEventPlugin', function() {
}
});
- it('A non-interactive tags click when disabled', function() {
+ it('A non-interactive tags click when disabled', function () {
const element =
;
expectClickThru(mounted(element));
});
- it('A non-interactive tags clicks bubble when disabled', function() {
+ it('A non-interactive tags clicks bubble when disabled', function () {
const element = mounted(
@@ -69,7 +69,7 @@ describe('SimpleEventPlugin', function() {
expect(onClick).toHaveBeenCalledTimes(1);
});
- it('does not register a click when clicking a child of a disabled element', function() {
+ it('does not register a click when clicking a child of a disabled element', function () {
const element = mounted(