Prettier 1.2 (#9462)
Ben Alpert committed
Apr 20, 2017 at 11:18 UTC
b1768b5a48d1f82e4ef4150e0036c5f846d3758a
168 files changed
+911
-813
package.json
+1
-1
@@ -72,7 +72,7 @@
72
"ncp": "^2.0.0",
73
"object-assign": "^4.1.1",
74
"platform": "^1.1.0",
75
- "prettier": "^0.22.0",
75
+ "prettier": "^1.2.2",
76
"prop-types": "^15.5.8",
77
"rimraf": "^2.6.1",
78
"rollup": "^0.41.6",
scripts/error-codes/__tests__/dev-expression-with-codes-test.js
+2
-1
@@ -76,7 +76,8 @@ var invariant = require('invariant');`
76
});
77
78
it('should only add `reactProdInvariant` once', () => {
79
- var expectedInvariantTransformResult = '!condition ? ' +
79
+ var expectedInvariantTransformResult =
80
+ '!condition ? ' +
81
"process.env.NODE_ENV !== 'production' ? " +
82
"invariant(false, 'Do not override existing functions.') : " +
83
`_prodInvariant('16') : void 0;`;
scripts/facts-tracker/index.js
+7
-5
@@ -29,8 +29,9 @@ var isCI = !!process.env.TRAVIS_REPO_SLUG;
29
30
if (isCI) {
31
var branch = process.env.TRAVIS_BRANCH || process.env.CIRCLE_BRANCH;
32
- var isPullRequest = (!!process.env.TRAVIS_PULL_REQUEST &&
33
- process.env.TRAVIS_PULL_REQUEST !== 'false') ||
32
+ var isPullRequest =
33
+ (!!process.env.TRAVIS_PULL_REQUEST &&
34
+ process.env.TRAVIS_PULL_REQUEST !== 'false') ||
35
!!process.env.CI_PULL_REQUEST;
36
37
if (branch !== 'master') {
@@ -117,7 +118,8 @@ function checkoutFactsFolder() {
118
if (!fs.existsSync(factsFolder)) {
119
var repoURL;
120
if (isCI) {
120
- repoURL = 'https://' +
121
+ repoURL =
122
+ 'https://' +
123
process.env.GITHUB_USER +
124
'@github.com/' +
125
repoSlug +
@@ -165,8 +167,8 @@ for (var i = 2; i < process.argv.length; i += 2) {
167
} catch (e) {
168
// ignore error
169
}
168
- var lastValue = lastLine &&
169
- lastLine.replace(/^[^\t]+\t[^\t]+\t/, '').slice(0, -1); // commit hash \t timestamp \t // trailing \n
170
+ var lastValue =
171
+ lastLine && lastLine.replace(/^[^\t]+\t[^\t]+\t/, '').slice(0, -1); // commit hash \t timestamp \t // trailing \n
172
173
if (value !== lastValue) {
174
fs.appendFileSync(
scripts/jest/preprocessor.js
+2
-1
@@ -66,7 +66,8 @@ module.exports = {
66
return tsPreprocessor.compile(src, filePath);
67
}
68
if (
69
- !filePath.match(/\/node_modules\//) && !filePath.match(/\/third_party\//)
69
+ !filePath.match(/\/node_modules\//) &&
70
+ !filePath.match(/\/third_party\//)
71
) {
72
// for test files, we also apply the async-await transform, but we want to
73
// make sure we don't accidentally apply that transform to product code.
scripts/jest/setupSpecEquivalenceReporter.js
+1
-1
@@ -18,7 +18,7 @@ global.expect = function() {
18
return expect.apply(this, arguments);
19
};
20
21
-beforeEach(() => numExpectations = 0);
21
+beforeEach(() => (numExpectations = 0));
22
23
jasmine.currentEnv_.addReporter({
24
specDone: spec => {
scripts/jest/ts-preprocessor.js
+4
-2
@@ -10,11 +10,13 @@ var tsOptions = {
10
};
11
12
function formatErrorMessage(error) {
13
- return error.file.filename +
13
+ return (
14
+ error.file.filename +
15
'(' +
16
error.file.getLineAndCharacterOfPosition(error.start).line +
17
'): ' +
17
- error.messageText;
18
+ error.messageText
19
+ );
20
}
21
22
function compile(content, contentFilename) {
scripts/rollup/build.js
+4
-3
@@ -327,8 +327,8 @@ function createBundle(bundle, bundleType) {
327
}
328
329
const filename = getFilename(bundle.name, bundle.hasteName, bundleType);
330
- const logKey = chalk.white.bold(filename) +
331
- chalk.dim(` (${bundleType.toLowerCase()})`);
330
+ const logKey =
331
+ chalk.white.bold(filename) + chalk.dim(` (${bundleType.toLowerCase()})`);
332
const format = getFormat(bundleType);
333
const packageName = Packaging.getPackageName(bundle.name);
334
@@ -362,7 +362,8 @@ function createBundle(bundle, bundleType) {
362
bundleType,
363
bundle.hasteName
364
)
365
- ))
365
+ )
366
+ )
367
.then(() => Packaging.createNodePackage(bundleType, packageName, filename))
368
.then(() => {
369
console.log(`${chalk.bgGreen.black(' COMPLETE ')} ${logKey}\n`);
scripts/rollup/packaging.js
+4
-2
@@ -126,7 +126,8 @@ function copyNodePackageTemplate(packageName) {
126
Promise.all([
127
asyncCopyTo(resolve('./LICENSE'), `${to}/LICENSE`),
128
asyncCopyTo(resolve('./PATENTS'), `${to}/PATENTS`),
129
- ]));
129
+ ])
130
+ );
131
} else {
132
return Promise.resolve();
133
}
@@ -136,7 +137,8 @@ function createNodePackage(bundleType, packageName, filename) {
137
// the only case where we don't want to copy the package is for FB bundles
138
if (bundleType !== FB_DEV && bundleType !== FB_PROD) {
139
return copyNodePackageTemplate(packageName).then(() =>
139
- copyBundleIntoNodePackage(packageName, filename, bundleType));
140
+ copyBundleIntoNodePackage(packageName, filename, bundleType)
141
+ );
142
}
143
return Promise.resolve();
144
}
scripts/rollup/shims/facebook-www/EventPluginHub.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginHub;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginHub;
scripts/rollup/shims/facebook-www/EventPluginUtils.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginUtils;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginUtils;
scripts/rollup/shims/facebook-www/EventPropagators.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPropagators;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPropagators;
scripts/rollup/shims/facebook-www/ReactBrowserEventEmitter.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactBrowserEventEmitter;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactBrowserEventEmitter;
scripts/rollup/shims/facebook-www/ReactChildren.js
+3
-4
@@ -11,10 +11,9 @@
11
12
'use strict';
13
14
-const {
15
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
-} = require('React');
14
+const {__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} = require('React');
15
16
// TODO: can't reexport public API because of
17
// mapIntoWithKeyPrefixInternal() dependency in an addon.
20
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactChildren;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactChildren;
scripts/rollup/shims/facebook-www/ReactDOMComponentTree.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMComponentTree;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMComponentTree;
scripts/rollup/shims/facebook-www/ReactDOMInputSelection.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMInputSelection;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMInputSelection;
scripts/rollup/shims/facebook-www/ReactDOMSelection.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMSelection;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMSelection;
scripts/rollup/shims/facebook-www/ReactElement.js
+1
-5
@@ -10,11 +10,7 @@
10
*/
11
'use strict';
12
13
-const {
14
- createElement,
15
- createFactory,
16
- isValidElement,
17
-} = require('React');
13
+const {createElement, createFactory, isValidElement} = require('React');
14
15
module.exports = {
16
createElement,
scripts/rollup/shims/facebook-www/ReactErrorUtils.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactErrorUtils;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactErrorUtils;
scripts/rollup/shims/facebook-www/ReactFiberErrorLogger.js
+2
-1
@@ -22,5 +22,6 @@ const ReactFiberErrorLoggerStackShim = {
22
},
23
};
24
25
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactFiberErrorLogger ||
25
+module.exports =
26
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactFiberErrorLogger ||
27
ReactFiberErrorLoggerStackShim;
scripts/rollup/shims/facebook-www/ReactInputSelection.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactInputSelection;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactInputSelection;
scripts/rollup/shims/facebook-www/ReactInstanceMap.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactInstanceMap;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactInstanceMap;
scripts/rollup/shims/facebook-www/ReactPerf.js
+2
-1
@@ -34,5 +34,6 @@ const ReactPerfFiberShim = {
34
getMeasurementsSummaryMap: emptyFunction,
35
};
36
37
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf ||
37
+module.exports =
38
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf ||
39
ReactPerfFiberShim;
scripts/rollup/shims/facebook-www/SyntheticEvent.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticEvent;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticEvent;
scripts/rollup/shims/facebook-www/SyntheticKeyboardEvent.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticKeyboardEvent;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticKeyboardEvent;
scripts/rollup/shims/facebook-www/SyntheticMouseEvent.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticMouseEvent;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticMouseEvent;
scripts/rollup/shims/facebook-www/SyntheticUIEvent.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticUIEvent;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SyntheticUIEvent;
scripts/rollup/shims/facebook-www/findDOMNode.js
+1
-3
@@ -11,8 +11,6 @@
11
12
'use strict';
13
14
-const {
15
- findDOMNode,
16
-} = require('ReactDOM-fb');
14
+const {findDOMNode} = require('ReactDOM-fb');
15
16
module.exports = findDOMNode;
scripts/rollup/shims/facebook-www/flattenChildren.js
+3
-4
@@ -11,8 +11,7 @@
11
12
'use strict';
13
14
-const {
15
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
-} = require('React');
14
+const {__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} = require('React');
15
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.flattenChildren;
16
+module.exports =
17
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.flattenChildren;
scripts/rollup/shims/facebook-www/getComponentName.js
+3
-4
@@ -11,8 +11,7 @@
11
12
'use strict';
13
14
-const {
15
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
-} = require('React');
14
+const {__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} = require('React');
15
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getComponentName;
16
+module.exports =
17
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getComponentName;
scripts/rollup/shims/facebook-www/getEventCharCode.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getEventCharCode;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getEventCharCode;
scripts/rollup/shims/facebook-www/getEventTarget.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getEventTarget;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getEventTarget;
scripts/rollup/shims/facebook-www/getVendorPrefixedEventName.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getVendorPrefixedEventName;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getVendorPrefixedEventName;
scripts/rollup/shims/facebook-www/isEventSupported.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.isEventSupported;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.isEventSupported;
scripts/rollup/shims/facebook-www/setInnerHTML.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.setInnerHTML;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.setInnerHTML;
scripts/rollup/shims/facebook-www/setTextContent.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactDOM-fb');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.setTextContent;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.setTextContent;
scripts/rollup/shims/react-native/NativeMethodsMixin.js
+2
-1
@@ -16,4 +16,5 @@ const {
16
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
17
} = require('ReactNative');
18
19
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.NativeMethodsMixin;
19
+module.exports =
20
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.NativeMethodsMixin;
scripts/rollup/shims/react-native/ReactDebugTool.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactNative');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDebugTool;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDebugTool;
scripts/rollup/shims/react-native/ReactErrorUtils.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactNative');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactErrorUtils;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactErrorUtils;
scripts/rollup/shims/react-native/ReactNativeComponentTree.js
+2
-1
@@ -16,4 +16,5 @@ const {
16
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
17
} = require('ReactNative');
18
19
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactNativeComponentTree;
19
+module.exports =
20
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactNativeComponentTree;
scripts/rollup/shims/react-native/ReactNativePropRegistry.js
+2
-1
@@ -16,4 +16,5 @@ const {
16
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
17
} = require('ReactNative');
18
19
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactNativePropRegistry;
19
+module.exports =
20
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactNativePropRegistry;
scripts/rollup/shims/react-native/TouchHistoryMath.js
+2
-1
@@ -15,4 +15,5 @@ const {
15
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16
} = require('ReactNative');
17
18
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.TouchHistoryMath;
18
+module.exports =
19
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.TouchHistoryMath;
scripts/rollup/shims/react-native/createReactNativeComponentClass.js
+2
-1
@@ -16,4 +16,5 @@ const {
16
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
17
} = require('ReactNative');
18
19
-module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.createReactNativeComponentClass;
19
+module.exports =
20
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.createReactNativeComponentClass;
scripts/rollup/shims/react-native/findNodeHandle.js
+2
-1
@@ -21,7 +21,8 @@ let realFindNodeHandle = null;
21
22
function findNodeHandle(componentOrHandle: any): ?number {
23
if (realFindNodeHandle === null) {
24
- realFindNodeHandle = require('ReactNative').__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.findNodeHandle;
24
+ realFindNodeHandle = require('ReactNative')
25
+ .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.findNodeHandle;
26
}
27
return realFindNodeHandle(componentOrHandle);
28
}
scripts/rollup/shims/rollup/ReactDebugCurrentFrameRollupShim.js
+2
-1
@@ -1,3 +1,4 @@
1
-var ReactInternals = require('react').__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1
+var ReactInternals = require('react')
2
+ .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
3
4
module.exports = ReactInternals.ReactDebugCurrentFrame;
scripts/rollup/stats.js
+4
-2
@@ -65,8 +65,10 @@ function printResults() {
65
percentChange(prevGzip, gzip),
66
]);
67
});
68
- return table.toString() +
69
- `\n\nThe difference was compared to the last build on "${chalk.green.bold(prevBuildResults.branch)}" branch.\n`;
68
+ return (
69
+ table.toString() +
70
+ `\n\nThe difference was compared to the last build on "${chalk.green.bold(prevBuildResults.branch)}" branch.\n`
71
+ );
72
}
73
74
module.exports = {
scripts/tasks/version-check.js
+6
-3
@@ -11,9 +11,12 @@
11
12
const reactVersion = require('../../package.json').version;
13
const versions = {
14
- 'packages/react/package.json': require('../../packages/react/package.json').version,
15
- 'packages/react-dom/package.json': require('../../packages/react-dom/package.json').version,
16
- 'packages/react-test-renderer/package.json': require('../../packages/react-test-renderer/package.json').version,
14
+ 'packages/react/package.json': require('../../packages/react/package.json')
15
+ .version,
16
+ 'packages/react-dom/package.json': require('../../packages/react-dom/package.json')
17
+ .version,
18
+ 'packages/react-test-renderer/package.json': require('../../packages/react-test-renderer/package.json')
19
+ .version,
20
'src/ReactVersion.js': require('../../src/ReactVersion'),
21
};
22
src/__mocks__/UIManager.js
+10
-7
@@ -66,10 +66,8 @@ var RCTUIManager = {
66
function dumpSubtree(tag, indent) {
67
const info = views.get(tag);
68
let out = '';
69
- out += ' '.repeat(indent) +
70
- info.viewName +
71
- ' ' +
72
- JSON.stringify(info.props);
69
+ out +=
70
+ ' '.repeat(indent) + info.viewName + ' ' + JSON.stringify(info.props);
71
for (const child of info.children) {
72
out += '\n' + dumpSubtree(child, indent + 2);
73
}
@@ -104,9 +102,14 @@ var RCTUIManager = {
102
insertSubviewAtIndex(parentTag, tag, i);
103
});
104
}),
107
- manageChildren: jest.fn(function manageChildren(parentTag, moveFromIndices = [
108
- ], moveToIndices = [], addChildReactTags = [], addAtIndices = [
109
- ], removeAtIndices = []) {
105
+ manageChildren: jest.fn(function manageChildren(
106
+ parentTag,
107
+ moveFromIndices = [],
108
+ moveToIndices = [],
109
+ addChildReactTags = [],
110
+ addAtIndices = [],
111
+ removeAtIndices = [],
112
+ ) {
113
autoCreateRoot(parentTag);
114
// This logic ported from iOS (RCTUIManager.m)
115
invariant(
src/isomorphic/children/__tests__/ReactChildren-test.js
+4
-2
@@ -725,7 +725,8 @@ describe('ReactChildren', () => {
725
);
726
727
var mappedWithClone = React.Children.map(instance.props.children, element =>
728
- React.cloneElement(element));
728
+ React.cloneElement(element),
729
+ );
730
731
expect(mapped[0].key).toBe(mappedWithClone[0].key);
732
});
@@ -743,7 +744,8 @@ describe('ReactChildren', () => {
744
);
745
746
var mappedWithClone = React.Children.map(instance.props.children, element =>
746
- React.cloneElement(element, {key: 'unique'}));
747
+ React.cloneElement(element, {key: 'unique'}),
748
+ );
749
750
expect(mapped[0].key).toBe(mappedWithClone[0].key);
751
});
src/isomorphic/children/traverseAllChildren.js
+3
-4
@@ -19,9 +19,7 @@ var KeyEscapeUtils = require('KeyEscapeUtils');
19
var warning = require('fbjs/lib/warning');
20
21
if (__DEV__) {
22
- var {
23
- getCurrentStackAddendum,
24
- } = require('ReactComponentTreeHook');
22
+ var {getCurrentStackAddendum} = require('ReactComponentTreeHook');
23
}
24
25
var SEPARATOR = '.';
@@ -146,7 +144,8 @@ function traverseAllChildrenImpl(
144
} else if (type === 'object') {
145
var addendum = '';
146
if (__DEV__) {
149
- addendum = ' If you meant to render a collection of children, use an array ' +
147
+ addendum =
148
+ ' If you meant to render a collection of children, use an array ' +
149
'instead.' +
150
getCurrentStackAddendum();
151
}
src/isomorphic/classic/class/__tests__/create-react-class-integration-test.js
+2
-1
@@ -326,7 +326,8 @@ describe('create-react-class-integration', () => {
326
},
327
});
328
expect(() =>
329
- ReactTestUtils.renderIntoDocument(<Component />)).not.toThrow();
329
+ ReactTestUtils.renderIntoDocument(<Component />),
330
+ ).not.toThrow();
331
});
332
333
it('should throw when using legacy factories', () => {
src/isomorphic/classic/element/ReactElement.js
+4
-2
@@ -374,9 +374,11 @@ ReactElement.cloneElement = function(element, config, children) {
374
* @final
375
*/
376
ReactElement.isValidElement = function(object) {
377
- return typeof object === 'object' &&
377
+ return (
378
+ typeof object === 'object' &&
379
object !== null &&
379
- object.$$typeof === REACT_ELEMENT_TYPE;
380
+ object.$$typeof === REACT_ELEMENT_TYPE
381
+ );
382
};
383
384
module.exports = ReactElement;
src/isomorphic/classic/element/ReactElementValidator.js
+6
-5
@@ -29,9 +29,7 @@ if (__DEV__) {
29
var checkPropTypes = require('prop-types/checkPropTypes');
30
var warning = require('fbjs/lib/warning');
31
var ReactDebugCurrentFrame = require('ReactDebugCurrentFrame');
32
- var {
33
- getCurrentStackAddendum,
34
- } = require('ReactComponentTreeHook');
32
+ var {getCurrentStackAddendum} = require('ReactComponentTreeHook');
33
}
34
35
function getDeclarationErrorAddendum() {
@@ -107,7 +105,9 @@ function validateExplicitKey(element, parentType) {
105
// assigning it a key.
106
var childOwner = '';
107
if (
110
- element && element._owner && element._owner !== ReactCurrentOwner.current
108
+ element &&
109
+ element._owner &&
110
+ element._owner !== ReactCurrentOwner.current
111
) {
112
// Give the component that originally created this child.
113
childOwner = ` It was passed a child from ${getComponentName(element._owner)}.`;
@@ -219,7 +219,8 @@ var ReactElementValidator = {
219
type !== null &&
220
Object.keys(type).length === 0)
221
) {
222
- info += ' You likely forgot to export your component from the file ' +
222
+ info +=
223
+ ' You likely forgot to export your component from the file ' +
224
"it's defined in.";
225
}
226
src/isomorphic/classic/element/__tests__/ReactElement-test.js
+1
-1
@@ -143,7 +143,7 @@ describe('ReactElement', () => {
143
144
it('returns an immutable element', () => {
145
var element = React.createFactory(ComponentClass)();
146
- expect(() => element.type = 'div').toThrow();
146
+ expect(() => (element.type = 'div')).toThrow();
147
});
148
149
it('does not reuse the original config object', () => {
src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
+6
-3
@@ -54,9 +54,11 @@ function typeCheckFail(declaration, value, expectedMessage) {
54
}
55
56
function typeCheckFailRequiredValues(declaration) {
57
- var specifiedButIsNullMsg = 'The prop `testProp` is marked as required in ' +
57
+ var specifiedButIsNullMsg =
58
+ 'The prop `testProp` is marked as required in ' +
59
'`testComponent`, but its value is `null`.';
59
- var unspecifiedMsg = 'The prop `testProp` is marked as required in ' +
60
+ var unspecifiedMsg =
61
+ 'The prop `testProp` is marked as required in ' +
62
'`testComponent`, but its value is \`undefined\`.';
63
64
var propTypes = {testProp: declaration};
@@ -602,7 +604,8 @@ describe('ReactPropTypes', () => {
604
});
605
606
it('should warn for invalid values', () => {
605
- var failMessage = 'Invalid prop `testProp` supplied to ' +
607
+ var failMessage =
608
+ 'Invalid prop `testProp` supplied to ' +
609
'`testComponent`, expected a ReactNode.';
610
typeCheckFail(PropTypes.node, true, failMessage);
611
typeCheckFail(PropTypes.node, function() {}, failMessage);
src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+1
-1
@@ -64,7 +64,7 @@ describe('ReactJSXElement', () => {
64
65
it('returns an immutable element', () => {
66
var element = <Component />;
67
- expect(() => element.type = 'div').toThrow();
67
+ expect(() => (element.type = 'div')).toThrow();
68
});
69
70
it('does not reuse the object that is spread into props', () => {
src/renderers/__tests__/ReactComponent-test.js
+6
-4
@@ -157,9 +157,11 @@ describe('ReactComponent', () => {
157
158
class Component extends React.Component {
159
render() {
160
- var inner = <Wrapper object={innerObj} ref={c => this.innerRef = c} />;
160
+ var inner = (
161
+ <Wrapper object={innerObj} ref={c => (this.innerRef = c)} />
162
+ );
163
var outer = (
162
- <Wrapper object={outerObj} ref={c => this.outerRef = c}>
164
+ <Wrapper object={outerObj} ref={c => (this.outerRef = c)}>
165
{inner}
166
</Wrapper>
167
);
@@ -194,14 +196,14 @@ describe('ReactComponent', () => {
196
getInner = () => {
197
// (With old-style refs, it's impossible to get a ref to this div
198
// because Wrapper is the current owner when this function is called.)
197
- return <div className="inner" ref={c => this.innerRef = c} />;
199
+ return <div className="inner" ref={c => (this.innerRef = c)} />;
200
};
201
202
render() {
203
return (
204
<Wrapper
205
title="wrapper"
204
- ref={c => this.wrapperRef = c}
206
+ ref={c => (this.wrapperRef = c)}
207
getContent={this.getInner}
208
/>
209
);
src/renderers/__tests__/ReactComponentTreeHook-test.native.js
+3
-2
@@ -1992,7 +1992,8 @@ describeStack('ReactComponentTreeHook', () => {
1992
1993
ReactNative.unmountComponentAtNode(1);
1994
expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
1995
- expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([
1996
- ]);
1995
+ expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(
1996
+ [],
1997
+ );
1998
});
1999
});
src/renderers/__tests__/ReactCompositeComponent-test.js
+5
-3
@@ -36,8 +36,10 @@ describe('ReactCompositeComponent', () => {
36
shallowEqual = require('fbjs/lib/shallowEqual');
37
38
shallowCompare = function(instance, nextProps, nextState) {
39
- return !shallowEqual(instance.props, nextProps) ||
40
- !shallowEqual(instance.state, nextState);
39
+ return (
40
+ !shallowEqual(instance.props, nextProps) ||
41
+ !shallowEqual(instance.state, nextState)
42
+ );
43
};
44
45
MorphingComponent = class extends React.Component {
@@ -938,7 +940,7 @@ describe('ReactCompositeComponent', () => {
940
941
var parentInstance = null;
942
ReactDOM.render(
941
- <Parent ref={inst => parentInstance = inst}>
943
+ <Parent ref={inst => (parentInstance = inst)}>
944
<ChildWithoutContext>
945
A1
946
<GrandChild>A2</GrandChild>
src/renderers/__tests__/ReactCompositeComponentState-test.js
+4
-7
@@ -93,13 +93,10 @@ describe('ReactCompositeComponent-state', () => {
93
// No longer a public API, but we can test that it works internally by
94
// reaching into the updater.
95
this.updater.enqueueReplaceState(this, {color: undefined});
96
- this.setState(
97
- function(state) {
98
- this.peekAtState('before-setState-again-receiveProps', state);
99
- return {color: newProps.nextColor};
100
- },
101
- this.peekAtCallback('setState-receiveProps'),
102
- );
96
+ this.setState(function(state) {
97
+ this.peekAtState('before-setState-again-receiveProps', state);
98
+ return {color: newProps.nextColor};
99
+ }, this.peekAtCallback('setState-receiveProps'));
100
this.setState(function(state) {
101
this.peekAtState('after-setState-receiveProps', state);
102
});
src/renderers/__tests__/ReactErrorBoundaries-test.js
+1
-1
@@ -1878,7 +1878,7 @@ describe('ReactErrorBoundaries', () => {
1878
var container = document.createElement('div');
1879
ReactDOM.render(
1880
<ErrorBoundary>
1881
- <Stateful ref={inst => statefulInst = inst} />
1881
+ <Stateful ref={inst => (statefulInst = inst)} />
1882
</ErrorBoundary>,
1883
container,
1884
);
src/renderers/__tests__/ReactIdentity-test.js
+5
-4
@@ -26,7 +26,7 @@ describe('ReactIdentity', () => {
26
it('should allow key property to express identity', () => {
27
var node;
28
var Component = props => (
29
- <div ref={c => node = c}>
29
+ <div ref={c => (node = c)}>
30
<div key={props.swap ? 'banana' : 'apple'} />
31
<div key={props.swap ? 'apple' : 'banana'} />
32
</div>
@@ -52,11 +52,11 @@ describe('ReactIdentity', () => {
52
var node1;
53
var node2;
54
ReactDOM.render(
55
- <Wrapper key="wrap1"><span ref={c => node1 = c} /></Wrapper>,
55
+ <Wrapper key="wrap1"><span ref={c => (node1 = c)} /></Wrapper>,
56
container,
57
);
58
ReactDOM.render(
59
- <Wrapper key="wrap2"><span ref={c => node2 = c} /></Wrapper>,
59
+ <Wrapper key="wrap2"><span ref={c => (node2 = c)} /></Wrapper>,
60
container,
61
);
62
@@ -92,7 +92,8 @@ describe('ReactIdentity', () => {
92
});
93
94
it('should not allow scripts in keys to execute', () => {
95
- var h4x0rKey = '"><script>window[\'YOUVEBEENH4X0RED\']=true;</script><div id="';
95
+ var h4x0rKey =
96
+ '"><script>window[\'YOUVEBEENH4X0RED\']=true;</script><div id="';
97
98
var attachedContainer = document.createElement('div');
99
document.body.appendChild(attachedContainer);
src/renderers/__tests__/ReactMultiChildReconcile-test.js
+4
-7
@@ -140,13 +140,10 @@ class FriendsStatusDisplay extends React.Component {
140
}
141
142
function getInternalStateByUserName(statusDisplays) {
143
- return Object.keys(statusDisplays).reduce(
144
- (acc, key) => {
145
- acc[key] = statusDisplays[key].getInternalState();
146
- return acc;
147
- },
148
- {},
149
- );
143
+ return Object.keys(statusDisplays).reduce((acc, key) => {
144
+ acc[key] = statusDisplays[key].getInternalState();
145
+ return acc;
146
+ }, {});
147
}
148
149
/**
src/renderers/__tests__/ReactUpdates-test.js
+2
-2
@@ -523,7 +523,7 @@ describe('ReactUpdates', () => {
523
// If we're using Fiber, we use Portals instead to achieve this.
524
if (ReactDOMFeatureFlags.useFiber) {
525
portal = ReactDOM.unstable_createPortal(
526
- <B ref={n => b = n} />,
526
+ <B ref={n => (b = n)} />,
527
bContainer,
528
);
529
}
@@ -541,7 +541,7 @@ describe('ReactUpdates', () => {
541
542
a = ReactTestUtils.renderIntoDocument(<A />);
543
if (!ReactDOMFeatureFlags.useFiber) {
544
- ReactDOM.render(<B ref={n => b = n} />, bContainer);
544
+ ReactDOM.render(<B ref={n => (b = n)} />, bContainer);
545
}
546
547
ReactDOM.unstable_batchedUpdates(function() {
src/renderers/__tests__/refs-destruction-test.js
+14
-21
@@ -47,15 +47,13 @@ describe('refs-destruction', () => {
47
true,
48
);
49
expect(
50
- Object.keys(testInstance.refs || {}).filter(
51
- key => testInstance.refs[key],
52
- ).length,
50
+ Object.keys(testInstance.refs || {}).filter(key => testInstance.refs[key])
51
+ .length,
52
).toEqual(1);
53
ReactDOM.unmountComponentAtNode(container);
54
expect(
56
- Object.keys(testInstance.refs || {}).filter(
57
- key => testInstance.refs[key],
58
- ).length,
55
+ Object.keys(testInstance.refs || {}).filter(key => testInstance.refs[key])
56
+ .length,
57
).toEqual(0);
58
});
59
@@ -66,15 +64,13 @@ describe('refs-destruction', () => {
64
true,
65
);
66
expect(
69
- Object.keys(testInstance.refs || {}).filter(
70
- key => testInstance.refs[key],
71
- ).length,
67
+ Object.keys(testInstance.refs || {}).filter(key => testInstance.refs[key])
68
+ .length,
69
).toEqual(1);
70
ReactDOM.render(<TestComponent destroy={true} />, container);
71
expect(
75
- Object.keys(testInstance.refs || {}).filter(
76
- key => testInstance.refs[key],
77
- ).length,
72
+ Object.keys(testInstance.refs || {}).filter(key => testInstance.refs[key])
73
+ .length,
74
).toEqual(0);
75
});
76
@@ -93,15 +89,12 @@ describe('refs-destruction', () => {
89
componentWillUnmount() {
90
var self = this;
91
// some async animation
96
- setTimeout(
97
- function() {
98
- expect(function() {
99
- ReactDOM.unmountComponentAtNode(self.div);
100
- }).not.toThrow();
101
- document.body.removeChild(self.div);
102
- },
103
- 0,
104
- );
92
+ setTimeout(function() {
93
+ expect(function() {
94
+ ReactDOM.unmountComponentAtNode(self.div);
95
+ }).not.toThrow();
96
+ document.body.removeChild(self.div);
97
+ }, 0);
98
}
99
100
render() {
src/renderers/art/ReactARTFiber.js
+9
-6
@@ -136,11 +136,13 @@ function isSameFont(oldFont, newFont) {
136
} else if (typeof newFont === 'string' || typeof oldFont === 'string') {
137
return false;
138
} else {
139
- return newFont.fontSize === oldFont.fontSize &&
139
+ return (
140
+ newFont.fontSize === oldFont.fontSize &&
141
newFont.fontStyle === oldFont.fontStyle &&
142
newFont.fontVariant === oldFont.fontVariant &&
143
newFont.fontWeight === oldFont.fontWeight &&
143
- newFont.fontFamily === oldFont.fontFamily;
144
+ newFont.fontFamily === oldFont.fontFamily
145
+ );
146
}
147
}
148
@@ -348,7 +350,7 @@ class Surface extends Component {
350
351
return (
352
<Tag
351
- ref={ref => this._tagRef = ref}
353
+ ref={ref => (this._tagRef = ref)}
354
accessKey={props.accessKey}
355
className={props.className}
356
draggable={props.draggable}
@@ -378,7 +380,7 @@ class Text extends React.Component {
380
// This means you can't have children that render into strings...
381
const T = TYPES.TEXT;
382
return (
381
- <T {...this.props} ref={t => this._text = t}>
383
+ <T {...this.props} ref={t => (this._text = t)}>
384
{childrenAsString(this.props.children)}
385
</T>
386
);
@@ -512,8 +514,9 @@ const ARTRenderer = ReactFiberReconciler({
514
scheduleDeferredCallback: ReactDOMFrameScheduling.rIC,
515
516
shouldSetTextContent(props) {
515
- return typeof props.children === 'string' ||
516
- typeof props.children === 'number';
517
+ return (
518
+ typeof props.children === 'string' || typeof props.children === 'number'
519
+ );
520
},
521
522
useSyncScheduling: true,
src/renderers/art/ReactARTStack.js
+8
-4
@@ -68,7 +68,8 @@ function createComponent(name) {
68
function injectAfter(parentNode, referenceNode, node) {
69
let beforeNode;
70
if (
71
- node.parentNode === parentNode && node.previousSibling === referenceNode
71
+ node.parentNode === parentNode &&
72
+ node.previousSibling === referenceNode
73
) {
74
return;
75
}
@@ -190,7 +191,8 @@ class Surface extends React.Component {
191
componentDidUpdate(oldProps) {
192
const node = this.node;
193
if (
193
- this.props.width != oldProps.width || this.props.height != oldProps.height
194
+ this.props.width != oldProps.width ||
195
+ this.props.height != oldProps.height
196
) {
197
node.resize(+this.props.width, +this.props.height);
198
}
@@ -562,11 +564,13 @@ const Text = createComponent('Text', RenderableMixin, {
564
if (typeof newFont === 'string' || typeof oldFont === 'string') {
565
return false;
566
}
565
- return newFont.fontSize === oldFont.fontSize &&
567
+ return (
568
+ newFont.fontSize === oldFont.fontSize &&
569
newFont.fontStyle === oldFont.fontStyle &&
570
newFont.fontVariant === oldFont.fontVariant &&
571
newFont.fontWeight === oldFont.fontWeight &&
569
- newFont.fontFamily === oldFont.fontFamily;
572
+ newFont.fontFamily === oldFont.fontFamily
573
+ );
574
},
575
576
receiveComponent: function(nextComponent, transaction, context) {
src/renderers/dom/ReactDOM.js
+5
-4
@@ -89,8 +89,9 @@ if (__DEV__) {
89
navigator.userAgent.indexOf('Firefox') > -1
90
) {
91
// Firefox does not have the issue with devtools loaded over file://
92
- var showFileUrlMessage = window.location.protocol.indexOf('http') ===
93
- -1 && navigator.userAgent.indexOf('Firefox') === -1;
92
+ var showFileUrlMessage =
93
+ window.location.protocol.indexOf('http') === -1 &&
94
+ navigator.userAgent.indexOf('Firefox') === -1;
95
console.debug(
96
'Download the React DevTools ' +
97
(showFileUrlMessage
@@ -113,8 +114,8 @@ if (__DEV__) {
114
115
// If we're in IE8, check to see if we are in compatibility mode and provide
116
// information on preventing compatibility mode
116
- var ieCompatibilityMode = document.documentMode &&
117
- document.documentMode < 8;
117
+ var ieCompatibilityMode =
118
+ document.documentMode && document.documentMode < 8;
119
120
warning(
121
!ieCompatibilityMode,
src/renderers/dom/fiber/ReactDOMFiber.js
+12
-11
@@ -47,10 +47,7 @@ var {
47
diffProperties,
48
updateProperties,
49
} = ReactDOMFiberComponent;
50
-var {
51
- precacheFiberNode,
52
- updateFiberProps,
53
-} = ReactDOMComponentTree;
50
+var {precacheFiberNode, updateFiberProps} = ReactDOMComponentTree;
51
52
if (__DEV__) {
53
var validateDOMNesting = require('validateDOMNesting');
@@ -135,7 +132,8 @@ var DOMRenderer = ReactFiberReconciler({
132
const type = rootContainerInstance.tagName;
133
const namespace = getChildNamespace(ownNamespace, type);
134
if (__DEV__) {
138
- const isMountingIntoDocument = rootContainerInstance.ownerDocument.documentElement ===
135
+ const isMountingIntoDocument =
136
+ rootContainerInstance.ownerDocument.documentElement ===
137
rootContainerInstance;
138
const validatedTag = isMountingIntoDocument
139
? '#document'
@@ -194,7 +192,8 @@ var DOMRenderer = ReactFiberReconciler({
192
const hostContextDev = ((hostContext: any): HostContextDev);
193
validateDOMNesting(type, null, null, hostContextDev.ancestorInfo);
194
if (
197
- typeof props.children === 'string' || typeof props.children === 'number'
195
+ typeof props.children === 'string' ||
196
+ typeof props.children === 'number'
197
) {
198
const string = '' + props.children;
199
const ownAncestorInfo = updatedAncestorInfo(
@@ -298,11 +297,13 @@ var DOMRenderer = ReactFiberReconciler({
297
},
298
299
shouldSetTextContent(props: Props): boolean {
301
- return typeof props.children === 'string' ||
300
+ return (
301
+ typeof props.children === 'string' ||
302
typeof props.children === 'number' ||
303
(typeof props.dangerouslySetInnerHTML === 'object' &&
304
props.dangerouslySetInnerHTML !== null &&
305
- typeof props.dangerouslySetInnerHTML.__html === 'string');
305
+ typeof props.dangerouslySetInnerHTML.__html === 'string')
306
+ );
307
},
308
309
resetTextContent(domElement: Instance): void {
@@ -399,7 +400,7 @@ function renderSubtreeIntoContainer(
400
container.removeChild(container.lastChild);
401
}
402
const newRoot = DOMRenderer.createContainer(container);
402
- root = (container._reactRootContainer = newRoot);
403
+ root = container._reactRootContainer = newRoot;
404
// Initial mount should not be batched.
405
DOMRenderer.unbatchedUpdates(() => {
406
DOMRenderer.updateContainer(children, newRoot, parentComponent, callback);
@@ -506,8 +507,8 @@ var ReactDOM = {
507
if (container._reactRootContainer) {
508
if (__DEV__) {
509
const rootEl = getReactRootElementInContainer(container);
509
- const renderedByDifferentReact = rootEl &&
510
- !ReactDOMComponentTree.getInstanceFromNode(rootEl);
510
+ const renderedByDifferentReact =
511
+ rootEl && !ReactDOMComponentTree.getInstanceFromNode(rootEl);
512
warning(
513
!renderedByDifferentReact,
514
"unmountComponentAtNode(): The node you're attempting to unmount " +
src/renderers/dom/fiber/ReactDOMFiberComponent.js
+8
-5
@@ -142,8 +142,8 @@ if (__DEV__) {
142
}
143
144
function ensureListeningTo(rootContainerElement, registrationName) {
145
- var isDocumentFragment = rootContainerElement.nodeType ===
146
- DOCUMENT_FRAGMENT_NODE;
145
+ var isDocumentFragment =
146
+ rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE;
147
var doc = isDocumentFragment
148
? rootContainerElement
149
: rootContainerElement.ownerDocument;
@@ -315,7 +315,8 @@ function setInitialDOMProperties(
315
} else if (isCustomComponentTag) {
316
DOMPropertyOperations.setValueForAttribute(domElement, propKey, nextProp);
317
} else if (
318
- DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)
318
+ DOMProperty.properties[propKey] ||
319
+ DOMProperty.isCustomAttribute(propKey)
320
) {
321
// If we're updating to null or undefined, we should remove the property
322
// from the DOM node instead of inadvertently setting to a string. This
@@ -359,7 +360,8 @@ function updateDOMProperties(
360
DOMPropertyOperations.deleteValueForAttribute(domElement, propKey);
361
}
362
} else if (
362
- DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)
363
+ DOMProperty.properties[propKey] ||
364
+ DOMProperty.isCustomAttribute(propKey)
365
) {
366
// If we're updating to null or undefined, we should remove the property
367
// from the DOM node instead of inadvertently setting to a string. This
@@ -648,7 +650,8 @@ var ReactDOMFiberComponent = {
650
}
651
}
652
} else if (
651
- propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN
653
+ propKey === DANGEROUSLY_SET_INNER_HTML ||
654
+ propKey === CHILDREN
655
) {
656
// Noop. This is handled by the clear text mechanism.
657
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING) {
src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
+15
-16
@@ -50,12 +50,12 @@ describe('ReactDOMFiber', () => {
50
it('should be called a callback argument', () => {
51
// mounting phase
52
let called = false;
53
- ReactDOM.render(<div>Foo</div>, container, () => called = true);
53
+ ReactDOM.render(<div>Foo</div>, container, () => (called = true));
54
expect(called).toEqual(true);
55
56
// updating phase
57
called = false;
58
- ReactDOM.render(<div>Foo</div>, container, () => called = true);
58
+ ReactDOM.render(<div>Foo</div>, container, () => (called = true));
59
expect(called).toEqual(true);
60
});
61
@@ -69,13 +69,13 @@ describe('ReactDOMFiber', () => {
69
70
// mounting phase
71
let called = false;
72
- ReactDOM.render(element, container, () => called = true);
72
+ ReactDOM.render(element, container, () => (called = true));
73
expect(called).toEqual(true);
74
75
// updating phase
76
called = false;
77
ReactDOM.unstable_batchedUpdates(() => {
78
- ReactDOM.render(element, container, () => called = true);
78
+ ReactDOM.render(element, container, () => (called = true));
79
});
80
expect(called).toEqual(true);
81
});
@@ -105,7 +105,7 @@ describe('ReactDOMFiber', () => {
105
106
let instance = null;
107
ReactDOM.render(
108
- <Text value="foo" ref={ref => instance = ref} />,
108
+ <Text value="foo" ref={ref => (instance = ref)} />,
109
container,
110
);
111
@@ -123,7 +123,7 @@ describe('ReactDOMFiber', () => {
123
}
124
125
let instance = null;
126
- ReactDOM.render(<Fragment ref={ref => instance = ref} />, container);
126
+ ReactDOM.render(<Fragment ref={ref => (instance = ref)} />, container);
127
128
expect(container.childNodes.length).toBe(2);
129
@@ -146,7 +146,7 @@ describe('ReactDOMFiber', () => {
146
}
147
148
let instance = null;
149
- ReactDOM.render(<Fragment ref={ref => instance = ref} />, container);
149
+ ReactDOM.render(<Fragment ref={ref => (instance = ref)} />, container);
150
151
expect(container.childNodes.length).toBe(2);
152
@@ -169,7 +169,7 @@ describe('ReactDOMFiber', () => {
169
}
170
171
let instance = null;
172
- ReactDOM.render(<Fragment ref={ref => instance = ref} />, container);
172
+ ReactDOM.render(<Fragment ref={ref => (instance = ref)} />, container);
173
174
expect(container.childNodes.length).toBe(2);
175
@@ -828,7 +828,7 @@ describe('ReactDOMFiber', () => {
828
{ReactDOM.unstable_createPortal(
829
<div
830
onClick={() => ops.push('portal clicked')}
831
- ref={n => portal = n}>
831
+ ref={n => (portal = n)}>
832
portal
833
</div>,
834
portalContainer,
@@ -877,18 +877,18 @@ describe('ReactDOMFiber', () => {
877
<div
878
onMouseEnter={() => ops.push('enter parent')}
879
onMouseLeave={() => ops.push('leave parent')}>
880
- <div ref={n => firstTarget = n} />
880
+ <div ref={n => (firstTarget = n)} />
881
{ReactDOM.unstable_createPortal(
882
<div
883
onMouseEnter={() => ops.push('enter portal')}
884
onMouseLeave={() => ops.push('leave portal')}
885
- ref={n => secondTarget = n}>
885
+ ref={n => (secondTarget = n)}>
886
portal
887
</div>,
888
portalContainer,
889
)}
890
</div>
891
- <div ref={n => thirdTarget = n} />
891
+ <div ref={n => (thirdTarget = n)} />
892
</div>,
893
container,
894
);
@@ -943,7 +943,7 @@ describe('ReactDOMFiber', () => {
943
}
944
945
let inst;
946
- ReactDOM.render([<Example key="a" ref={n => inst = n} />], container);
946
+ ReactDOM.render([<Example key="a" ref={n => (inst = n)} />], container);
947
const node = container.firstChild;
948
expect(node.tagName).toEqual('DIV');
949
@@ -1051,9 +1051,8 @@ describe('disableNewFiberFeatures', () => {
1051
/You may have returned undefined/,
1052
);
1053
expect(() =>
1054
- ReactDOM.render(<Render>[<div key="a" />]</Render>, container)).toThrow(
1055
- /You may have returned undefined/,
1056
- );
1054
+ ReactDOM.render(<Render>[<div key="a" />]</Render>, container),
1055
+ ).toThrow(/You may have returned undefined/);
1056
});
1057
1058
it('treats mocked render functions as if they return null', () => {
src/renderers/dom/shared/CSSPropertyOperations.js
+4
-3
@@ -181,8 +181,8 @@ var CSSPropertyOperations = {
181
}
182
if (styleValue != null) {
183
serialized += processStyleName(styleName) + ':';
184
- serialized += dangerousStyleValue(styleName, styleValue, component) +
185
- ';';
184
+ serialized +=
185
+ dangerousStyleValue(styleName, styleValue, component) + ';';
186
}
187
}
188
return serialized || null;
@@ -216,7 +216,8 @@ var CSSPropertyOperations = {
216
if (styleValue) {
217
style[styleName] = styleValue;
218
} else {
219
- var expansion = hasShorthandPropertyBug &&
219
+ var expansion =
220
+ hasShorthandPropertyBug &&
221
CSSProperty.shorthandPropertyExpansions[styleName];
222
if (expansion) {
223
// Shorthand property that IE8 won't like unsetting, so unset each
src/renderers/dom/shared/DOMProperty.js
+2
-1
@@ -141,7 +141,8 @@ var DOMPropertyInjection = {
141
};
142
143
/* eslint-disable max-len */
144
-var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
144
+var ATTRIBUTE_NAME_START_CHAR =
145
+ ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
146
/* eslint-enable max-len */
147
148
/**
src/renderers/dom/shared/DOMPropertyOperations.js
+7
-5
@@ -45,11 +45,13 @@ function isAttributeNameSafe(attributeName) {
45
}
46
47
function shouldIgnoreValue(propertyInfo, value) {
48
- return value == null ||
48
+ return (
49
+ value == null ||
50
(propertyInfo.hasBooleanValue && !value) ||
51
(propertyInfo.hasNumericValue && isNaN(value)) ||
52
(propertyInfo.hasPositiveNumericValue && value < 1) ||
52
- (propertyInfo.hasOverloadedBooleanValue && value === false);
53
+ (propertyInfo.hasOverloadedBooleanValue && value === false)
54
+ );
55
}
56
57
/**
@@ -63,9 +65,9 @@ var DOMPropertyOperations = {
65
* @return {string} Markup string.
66
*/
67
createMarkupForID: function(id) {
66
- return DOMProperty.ID_ATTRIBUTE_NAME +
67
- '=' +
68
- quoteAttributeValueForBrowser(id);
68
+ return (
69
+ DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id)
70
+ );
71
},
72
73
setAttributeForID: function(node, id) {
src/renderers/dom/shared/HTMLDOMPropertyConfig.js
+4
-2
@@ -16,8 +16,10 @@ var DOMProperty = require('DOMProperty');
16
var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
17
var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
18
var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
19
-var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
20
-var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
19
+var HAS_POSITIVE_NUMERIC_VALUE =
20
+ DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
21
+var HAS_OVERLOADED_BOOLEAN_VALUE =
22
+ DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
23
24
var HTMLDOMPropertyConfig = {
25
isCustomAttribute: RegExp.prototype.test.bind(
src/renderers/dom/shared/ReactBrowserEventEmitter.js
+4
-6
@@ -227,9 +227,8 @@ var ReactBrowserEventEmitter = Object.assign({}, ReactEventEmitterMixin, {
227
listenTo: function(registrationName, contentDocumentHandle) {
228
var mountAt = contentDocumentHandle;
229
var isListening = getListeningForDocument(mountAt);
230
- var dependencies = EventPluginRegistry.registrationNameDependencies[
231
- registrationName
232
- ];
230
+ var dependencies =
231
+ EventPluginRegistry.registrationNameDependencies[registrationName];
232
233
for (var i = 0; i < dependencies.length; i++) {
234
var dependency = dependencies[i];
@@ -312,9 +311,8 @@ var ReactBrowserEventEmitter = Object.assign({}, ReactEventEmitterMixin, {
311
312
isListeningToAllDependencies: function(registrationName, mountAt) {
313
var isListening = getListeningForDocument(mountAt);
315
- var dependencies = EventPluginRegistry.registrationNameDependencies[
316
- registrationName
317
- ];
314
+ var dependencies =
315
+ EventPluginRegistry.registrationNameDependencies[registrationName];
316
for (var i = 0; i < dependencies.length; i++) {
317
var dependency = dependencies[i];
318
if (
src/renderers/dom/shared/ReactDOMComponentTree.js
+5
-3
@@ -31,12 +31,14 @@ var internalEventHandlersKey = '__reactEventHandlers$' + randomKey;
31
* Check if a given node should be cached.
32
*/
33
function shouldPrecacheNode(node, nodeID) {
34
- return (node.nodeType === ELEMENT_NODE &&
35
- node.getAttribute(ATTR_NAME) === '' + nodeID) ||
34
+ return (
35
+ (node.nodeType === ELEMENT_NODE &&
36
+ node.getAttribute(ATTR_NAME) === '' + nodeID) ||
37
(node.nodeType === COMMENT_NODE &&
38
node.nodeValue === ' react-text: ' + nodeID + ' ') ||
39
(node.nodeType === COMMENT_NODE &&
39
- node.nodeValue === ' react-empty: ' + nodeID + ' ');
40
+ node.nodeValue === ' react-empty: ' + nodeID + ' ')
41
+ );
42
}
43
44
/**
src/renderers/dom/shared/ReactInputSelection.js
+4
-2
@@ -31,10 +31,12 @@ function isInDocument(node) {
31
var ReactInputSelection = {
32
hasSelectionCapabilities: function(elem) {
33
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
34
- return nodeName &&
34
+ return (
35
+ nodeName &&
36
((nodeName === 'input' && elem.type === 'text') ||
37
nodeName === 'textarea' ||
37
- elem.contentEditable === 'true');
38
+ elem.contentEditable === 'true')
39
+ );
40
},
41
42
getSelectionInformation: function() {
src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
+3
-3
@@ -76,7 +76,7 @@ describe('ReactBrowserEventEmitter', () => {
76
var CHILD_PROPS = {};
77
78
function Child(props) {
79
- return <div ref={c => CHILD = c} {...props} />;
79
+ return <div ref={c => (CHILD = c)} {...props} />;
80
}
81
82
class ChildWrapper extends React.PureComponent {
@@ -87,8 +87,8 @@ describe('ReactBrowserEventEmitter', () => {
87
88
function renderTree() {
89
ReactDOM.render(
90
- <div ref={c => GRANDPARENT = c} {...GRANDPARENT_PROPS}>
91
- <div ref={c => PARENT = c} {...PARENT_PROPS}>
90
+ <div ref={c => (GRANDPARENT = c)} {...GRANDPARENT_PROPS}>
91
+ <div ref={c => (PARENT = c)} {...PARENT_PROPS}>
92
<ChildWrapper {...CHILD_PROPS} />
93
</div>
94
</div>,
src/renderers/dom/shared/__tests__/ReactDOM-test.js
+2
-2
@@ -215,9 +215,9 @@ describe('ReactDOM', () => {
215
render() {
216
return (
217
<div>
218
- <input id="one" ref={r => input = input || r} />
218
+ <input id="one" ref={r => (input = input || r)} />
219
{this.props.showTwo &&
220
- <input id="two" ref={r => input2 = input2 || r} />}
220
+ <input id="two" ref={r => (input2 = input2 || r)} />}
221
</div>
222
);
223
}
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+1
-1
@@ -137,7 +137,7 @@ describe('ReactDOMComponent', () => {
137
}
138
139
ReactTestUtils.renderIntoDocument(<App />);
140
- expectDev(() => style.position = 'absolute').toThrow();
140
+ expectDev(() => (style.position = 'absolute')).toThrow();
141
});
142
143
it('should warn for unknown prop', () => {
src/renderers/dom/shared/__tests__/ReactDOMSVG-test.js
+27
-27
@@ -51,38 +51,38 @@ describe('ReactDOMSVG', () => {
51
svg4;
52
ReactDOM.render(
53
<div>
54
- <svg ref={el => svg = el}>
55
- <g ref={el => g = el} strokeWidth="5">
56
- <svg ref={el => svg2 = el}>
57
- <foreignObject ref={el => foreignObject = el}>
58
- <svg ref={el => svg3 = el}>
59
- <svg ref={el => svg4 = el} />
54
+ <svg ref={el => (svg = el)}>
55
+ <g ref={el => (g = el)} strokeWidth="5">
56
+ <svg ref={el => (svg2 = el)}>
57
+ <foreignObject ref={el => (foreignObject = el)}>
58
+ <svg ref={el => (svg3 = el)}>
59
+ <svg ref={el => (svg4 = el)} />
60
<image
61
- ref={el => image = el}
61
+ ref={el => (image = el)}
62
xlinkHref="http://i.imgur.com/w7GCRPb.png"
63
/>
64
</svg>
65
- <div ref={el => div = el} />
65
+ <div ref={el => (div = el)} />
66
</foreignObject>
67
</svg>
68
<image
69
- ref={el => image2 = el}
69
+ ref={el => (image2 = el)}
70
xlinkHref="http://i.imgur.com/w7GCRPb.png"
71
/>
72
- <foreignObject ref={el => foreignObject2 = el}>
73
- <div ref={el => div2 = el} />
72
+ <foreignObject ref={el => (foreignObject2 = el)}>
73
+ <div ref={el => (div2 = el)} />
74
</foreignObject>
75
</g>
76
</svg>
77
- <p ref={el => p = el}>
77
+ <p ref={el => (p = el)}>
78
<svg>
79
<image
80
- ref={el => image3 = el}
80
+ ref={el => (image3 = el)}
81
xlinkHref="http://i.imgur.com/w7GCRPb.png"
82
/>
83
</svg>
84
</p>
85
- <div ref={el => div3 = el} />
85
+ <div ref={el => (div3 = el)} />
86
</div>,
87
node,
88
);
@@ -137,25 +137,25 @@ describe('ReactDOMSVG', () => {
137
return null;
138
}
139
return (
140
- <g ref={el => g = el} strokeWidth="5">
141
- <svg ref={el => svg2 = el}>
142
- <foreignObject ref={el => foreignObject = el}>
143
- <svg ref={el => svg3 = el}>
144
- <svg ref={el => svg4 = el} />
140
+ <g ref={el => (g = el)} strokeWidth="5">
141
+ <svg ref={el => (svg2 = el)}>
142
+ <foreignObject ref={el => (foreignObject = el)}>
143
+ <svg ref={el => (svg3 = el)}>
144
+ <svg ref={el => (svg4 = el)} />
145
<image
146
- ref={el => image = el}
146
+ ref={el => (image = el)}
147
xlinkHref="http://i.imgur.com/w7GCRPb.png"
148
/>
149
</svg>
150
- <div ref={el => div = el} />
150
+ <div ref={el => (div = el)} />
151
</foreignObject>
152
</svg>
153
<image
154
- ref={el => image2 = el}
154
+ ref={el => (image2 = el)}
155
xlinkHref="http://i.imgur.com/w7GCRPb.png"
156
/>
157
- <foreignObject ref={el => foreignObject2 = el}>
158
- <div ref={el => div2 = el} />
157
+ <foreignObject ref={el => (foreignObject2 = el)}>
158
+ <div ref={el => (div2 = el)} />
159
</foreignObject>
160
</g>
161
);
@@ -164,7 +164,7 @@ describe('ReactDOMSVG', () => {
164
165
var node = document.createElement('div');
166
ReactDOM.render(
167
- <svg ref={el => svg = el}>
167
+ <svg ref={el => (svg = el)}>
168
<App />
169
</svg>,
170
node,
@@ -205,7 +205,7 @@ describe('ReactDOMSVG', () => {
205
var container = document.createElementNS('http://www.w3.org/2000/svg', 'g');
206
outerSVGRoot.appendChild(container);
207
var image;
208
- ReactDOM.render(<image ref={el => image = el} />, container);
208
+ ReactDOM.render(<image ref={el => (image = el)} />, container);
209
expect(image.namespaceURI).toBe('http://www.w3.org/2000/svg');
210
expect(image.tagName).toBe('image');
211
});
@@ -230,7 +230,7 @@ describe('ReactDOMSVG', () => {
230
);
231
outerSVGRoot.appendChild(container);
232
var div;
233
- ReactDOM.render(<div ref={el => div = el} />, container);
233
+ ReactDOM.render(<div ref={el => (div = el)} />, container);
234
expect(div.namespaceURI).toBe('http://www.w3.org/1999/xhtml');
235
expect(div.tagName).toBe('DIV');
236
});
src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
+24
-19
@@ -25,7 +25,8 @@ let ReactTestUtils;
25
// promisified version of ReactDOM.render()
26
function asyncReactDOMRender(reactElement, domElement) {
27
return new Promise(resolve =>
28
- ReactDOM.render(reactElement, domElement, resolve));
28
+ ReactDOM.render(reactElement, domElement, resolve),
29
+ );
30
}
31
// performs fn asynchronously and expects count errors logged to console.error.
32
// will fail the test if the count of errors logged is not equal to count.
@@ -38,7 +39,8 @@ async function expectErrors(fn, count) {
39
40
const result = await fn();
41
if (
41
- console.error.calls.count() !== count && console.error.calls.count() !== 0
42
+ console.error.calls.count() !== count &&
43
+ console.error.calls.count() !== 0
44
) {
45
console.log(
46
`We expected ${count} warning(s), but saw ${console.error.calls.count()} warning(s).`,
@@ -57,22 +59,20 @@ async function expectErrors(fn, count) {
59
// renders the reactElement into domElement, and expects a certain number of errors.
60
// returns a Promise that resolves when the render is complete.
61
function renderIntoDom(reactElement, domElement, errorCount = 0) {
60
- return expectErrors(
61
- async () => {
62
- ExecutionEnvironment.canUseDOM = true;
63
- await asyncReactDOMRender(reactElement, domElement);
64
- ExecutionEnvironment.canUseDOM = false;
65
- return domElement.firstChild;
66
- },
67
- errorCount,
68
- );
62
+ return expectErrors(async () => {
63
+ ExecutionEnvironment.canUseDOM = true;
64
+ await asyncReactDOMRender(reactElement, domElement);
65
+ ExecutionEnvironment.canUseDOM = false;
66
+ return domElement.firstChild;
67
+ }, errorCount);
68
}
69
70
async function renderIntoString(reactElement, errorCount = 0) {
71
return await expectErrors(
72
() =>
73
new Promise(resolve =>
75
- resolve(ReactDOMServer.renderToString(reactElement))),
74
+ resolve(ReactDOMServer.renderToString(reactElement)),
75
+ ),
76
errorCount,
77
);
78
}
@@ -108,7 +108,8 @@ const clientRenderOnServerString = async (element, errorCount = 0) => {
108
109
const clientRenderOnBadMarkup = (element, errorCount = 0) => {
110
var domElement = document.createElement('div');
111
- domElement.innerHTML = '<div id="badIdWhichWillCauseMismatch" data-reactroot="" data-reactid="1"></div>';
111
+ domElement.innerHTML =
112
+ '<div id="badIdWhichWillCauseMismatch" data-reactroot="" data-reactid="1"></div>';
113
return renderIntoDom(element, domElement, errorCount + 1);
114
};
115
@@ -155,16 +156,19 @@ function itThrows(desc, testFn) {
156
it(`throws ${desc}`, () => {
157
return testFn()
158
.then(() =>
158
- expect(false).toBe('The promise resolved and should not have.'))
159
+ expect(false).toBe('The promise resolved and should not have.'),
160
+ )
161
.catch(() => {});
162
});
163
}
164
165
function itThrowsWhenRendering(desc, testFn) {
166
itThrows(`when rendering ${desc} with server string render`, () =>
165
- testFn(serverRender));
167
+ testFn(serverRender),
168
+ );
169
itThrows(`when rendering ${desc} with clean client render`, () =>
167
- testFn(clientCleanRender));
170
+ testFn(clientCleanRender),
171
+ );
172
173
// we subtract one from the warning count here because the throw means that it won't
174
// get the usual markup mismatch warning.
@@ -172,7 +176,8 @@ function itThrowsWhenRendering(desc, testFn) {
176
`when rendering ${desc} with client render on top of bad server markup`,
177
() =>
178
testFn((element, warningCount = 0) =>
175
- clientRenderOnBadMarkup(element, warningCount - 1)),
179
+ clientRenderOnBadMarkup(element, warningCount - 1),
180
+ ),
181
);
182
}
183
@@ -1823,7 +1828,7 @@ describe('ReactDOMServerIntegration', () => {
1828
let refElement = null;
1829
class RefsComponent extends React.Component {
1830
render() {
1826
- return <div ref={e => refElement = e} />;
1831
+ return <div ref={e => (refElement = e)} />;
1832
}
1833
}
1834
const e = await clientRenderOnServerString(<RefsComponent />);
@@ -1844,7 +1849,7 @@ describe('ReactDOMServerIntegration', () => {
1849
let component = null;
1850
resetModules();
1851
await asyncReactDOMRender(
1847
- <RefsComponent ref={e => component = e} />,
1852
+ <RefsComponent ref={e => (component = e)} />,
1853
root,
1854
);
1855
expect(component.refs.myDiv).toBe(root.firstChild);
src/renderers/dom/shared/__tests__/ReactEventListener-test.js
+23
-17
@@ -123,13 +123,16 @@ describe('ReactEventListener', () => {
123
// node when the first event handlers are called; we'll still
124
// expect to receive a second call for the parent control.
125
var childNode = ReactDOM.findDOMNode(childControl);
126
- handleTopLevel.mockImplementation(
127
- function(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
128
- if (topLevelTarget === childNode) {
129
- ReactDOM.unmountComponentAtNode(childContainer);
130
- }
131
- },
132
- );
126
+ handleTopLevel.mockImplementation(function(
127
+ topLevelType,
128
+ topLevelTarget,
129
+ topLevelTargetID,
130
+ nativeEvent,
131
+ ) {
132
+ if (topLevelTarget === childNode) {
133
+ ReactDOM.unmountComponentAtNode(childContainer);
134
+ }
135
+ });
136
137
var callback = ReactEventListener.dispatchEvent.bind(null, 'test');
138
callback({
@@ -156,16 +159,19 @@ describe('ReactEventListener', () => {
159
// Suppose an event handler in each root enqueues an update to the
160
// childControl element -- the two updates should get batched together.
161
var childNode = ReactDOM.findDOMNode(childControl);
159
- handleTopLevel.mockImplementation(
160
- function(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
161
- ReactDOM.render(
162
- <div>{topLevelTarget === childNode ? '1' : '2'}</div>,
163
- childContainer,
164
- );
165
- // Since we're batching, neither update should yet have gone through.
166
- expect(childNode.textContent).toBe('Child');
167
- },
168
- );
162
+ handleTopLevel.mockImplementation(function(
163
+ topLevelType,
164
+ topLevelTarget,
165
+ topLevelTargetID,
166
+ nativeEvent,
167
+ ) {
168
+ ReactDOM.render(
169
+ <div>{topLevelTarget === childNode ? '1' : '2'}</div>,
170
+ childContainer,
171
+ );
172
+ // Since we're batching, neither update should yet have gone through.
173
+ expect(childNode.textContent).toBe('Child');
174
+ });
175
176
var callback = ReactEventListener.dispatchEvent.bind(
177
ReactEventListener,
src/renderers/dom/shared/__tests__/ReactRenderDocument-test.js
+2
-1
@@ -19,7 +19,8 @@ var getTestDocument;
19
20
var testDocument;
21
22
-var UNMOUNT_INVARIANT_MESSAGE = '<html> tried to unmount. ' +
22
+var UNMOUNT_INVARIANT_MESSAGE =
23
+ '<html> tried to unmount. ' +
24
'Because of cross-browser quirks it is impossible to unmount some ' +
25
'top-level components (eg <html>, <head>, and <body>) reliably and ' +
26
'efficiently. To fix this, have a single top-level component that ' +
src/renderers/dom/shared/eventPlugins/BeforeInputEventPlugin.js
+14
-8
@@ -22,8 +22,8 @@ import type {TopLevelTypes} from 'EventConstants';
22
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
23
var START_KEYCODE = 229;
24
25
-var canUseCompositionEvent = ExecutionEnvironment.canUseDOM &&
26
- 'CompositionEvent' in window;
25
+var canUseCompositionEvent =
26
+ ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window;
27
28
var documentMode = null;
29
if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
@@ -33,7 +33,8 @@ if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
33
// Webkit offers a very useful `textInput` event that can be used to
34
// directly represent `beforeInput`. The IE `textinput` event is not as
35
// useful, so we don't use it.
36
-var canUseTextInputEvent = ExecutionEnvironment.canUseDOM &&
36
+var canUseTextInputEvent =
37
+ ExecutionEnvironment.canUseDOM &&
38
'TextEvent' in window &&
39
!documentMode &&
40
!isPresto();
@@ -41,7 +42,8 @@ var canUseTextInputEvent = ExecutionEnvironment.canUseDOM &&
42
// In IE9+, we have access to composition events, but the data supplied
43
// by the native compositionend event may be incorrect. Japanese ideographic
44
// spaces, for instance (\u3000) are not recorded correctly.
44
-var useFallbackCompositionData = ExecutionEnvironment.canUseDOM &&
45
+var useFallbackCompositionData =
46
+ ExecutionEnvironment.canUseDOM &&
47
(!canUseCompositionEvent ||
48
(documentMode && documentMode > 8 && documentMode <= 11));
49
@@ -51,9 +53,11 @@ var useFallbackCompositionData = ExecutionEnvironment.canUseDOM &&
53
*/
54
function isPresto() {
55
var opera = window.opera;
54
- return typeof opera === 'object' &&
56
+ return (
57
+ typeof opera === 'object' &&
58
typeof opera.version === 'function' &&
56
- parseInt(opera.version(), 10) <= 12;
59
+ parseInt(opera.version(), 10) <= 12
60
+ );
61
}
62
63
var SPACEBAR_CODE = 32;
@@ -126,9 +130,11 @@ var hasSpaceKeypress = false;
130
* (cut, copy, select-all, etc.) even though no character is inserted.
131
*/
132
function isKeypressCommand(nativeEvent) {
129
- return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
133
+ return (
134
+ (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
135
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
131
- !(nativeEvent.ctrlKey && nativeEvent.altKey);
136
+ !(nativeEvent.ctrlKey && nativeEvent.altKey)
137
+ );
138
}
139
140
/**
src/renderers/dom/shared/eventPlugins/ChangeEventPlugin.js
+9
-5
@@ -67,8 +67,9 @@ var activeElementInst = null;
67
*/
68
function shouldUseChangeEvent(elem) {
69
var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
70
- return nodeName === 'select' ||
71
- (nodeName === 'input' && elem.type === 'file');
70
+ return (
71
+ nodeName === 'select' || (nodeName === 'input' && elem.type === 'file')
72
+ );
73
}
74
75
function manualDispatchChangeEvent(nativeEvent) {
@@ -116,7 +117,8 @@ var isInputEventSupported = false;
117
if (ExecutionEnvironment.canUseDOM) {
118
// IE9 claims to support the input event but fails to trigger it when
119
// deleting text, so we ignore its input events.
119
- isInputEventSupported = isEventSupported('input') &&
120
+ isInputEventSupported =
121
+ isEventSupported('input') &&
122
(!document.documentMode || document.documentMode > 9);
123
}
124
@@ -205,9 +207,11 @@ function shouldUseClickEvent(elem) {
207
// This approach works across all browsers, whereas `change` does not fire
208
// until `blur` in IE8.
209
var nodeName = elem.nodeName;
208
- return nodeName &&
210
+ return (
211
+ nodeName &&
212
nodeName.toLowerCase() === 'input' &&
210
- (elem.type === 'checkbox' || elem.type === 'radio');
213
+ (elem.type === 'checkbox' || elem.type === 'radio')
214
+ );
215
}
216
217
function getTargetInstForClickEvent(topLevelType, targetInst) {
src/renderers/dom/shared/eventPlugins/SelectEventPlugin.js
+7
-5
@@ -23,7 +23,8 @@ var getActiveElement = require('fbjs/lib/getActiveElement');
23
var isTextInputElement = require('isTextInputElement');
24
var shallowEqual = require('fbjs/lib/shallowEqual');
25
26
-var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM &&
26
+var skipSelectionChangeEvent =
27
+ ExecutionEnvironment.canUseDOM &&
28
'documentMode' in document &&
29
document.documentMode <= 11;
30
@@ -53,7 +54,8 @@ var mouseDown = false;
54
55
// Track whether all listeners exists for this plugin. If none exist, we do
56
// not extract events. See #3639.
56
-var isListeningToAllDependencies = ReactBrowserEventEmitter.isListeningToAllDependencies;
57
+var isListeningToAllDependencies =
58
+ ReactBrowserEventEmitter.isListeningToAllDependencies;
59
60
/**
61
* Get an object which is a unique representation of the current selection.
@@ -96,7 +98,9 @@ function constructSelectEvent(nativeEvent, nativeEventTarget) {
98
// fires only on input and textarea thus if there's no focused element we
99
// won't dispatch.
100
if (
99
- mouseDown || activeElement == null || activeElement !== getActiveElement()
101
+ mouseDown ||
102
+ activeElement == null ||
103
+ activeElement !== getActiveElement()
104
) {
105
return null;
106
}
@@ -177,7 +181,6 @@ var SelectEventPlugin = {
181
activeElementInst = null;
182
lastSelection = null;
183
break;
180
-
184
// Don't fire the event while the user is dragging. This matches the
185
// semantics of the native select event.
186
case 'topMouseDown':
@@ -187,7 +190,6 @@ var SelectEventPlugin = {
190
case 'topMouseUp':
191
mouseDown = false;
192
return constructSelectEvent(nativeEvent, nativeEventTarget);
190
-
193
// Chrome and IE fire non-standard event when selection is changed (and
194
// sometimes when it hasn't). IE's event fires out of order with respect
195
// to key and input events on deletion, so we discard it.
src/renderers/dom/shared/eventPlugins/__tests__/BeforeInputEventPlugin-test.js
+3
-2
@@ -67,7 +67,7 @@ describe('BeforeInputEventPlugin', function() {
67
}
68
69
function setElementText(node) {
70
- return args => node.innerHTML = args;
70
+ return args => (node.innerHTML = args);
71
}
72
73
function accumulateEvents(node, events) {
@@ -95,7 +95,8 @@ describe('BeforeInputEventPlugin', function() {
95
} else if (actual === null) {
96
throw new EventMismatchError(idx, 'Expected not to be null');
97
} else if (
98
- expected.type === null || !(actual instanceof expected.type)
98
+ expected.type === null ||
99
+ !(actual instanceof expected.type)
100
) {
101
throw new EventMismatchError(idx, 'Unexpected type: ' + actual);
102
} else {
src/renderers/dom/shared/hooks/ReactDOMInvalidARIAHook.js
+1
-3
@@ -21,9 +21,7 @@ var rARIA = new RegExp('^(aria)-[' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
21
22
if (__DEV__) {
23
var {ReactComponentTreeHook} = require('ReactGlobalSharedState');
24
- var {
25
- getStackAddendumByID,
26
- } = ReactComponentTreeHook;
24
+ var {getStackAddendumByID} = ReactComponentTreeHook;
25
}
26
27
function getStackAddendum(debugID) {
src/renderers/dom/shared/inputValueTracking.js
+4
-2
@@ -29,9 +29,11 @@ var ReactDOMComponentTree = require('ReactDOMComponentTree');
29
function isCheckable(elem: any) {
30
var type = elem.type;
31
var nodeName = elem.nodeName;
32
- return nodeName &&
32
+ return (
33
+ nodeName &&
34
nodeName.toLowerCase() === 'input' &&
34
- (type === 'checkbox' || type === 'radio');
35
+ (type === 'checkbox' || type === 'radio')
36
+ );
37
}
38
39
function getTracker(inst: any) {
src/renderers/dom/shared/setInnerHTML.js
+2
-2
@@ -29,8 +29,8 @@ var setInnerHTML = createMicrosoftUnsafeLocalFunction(function(node, html) {
29
// new markup in a temp node and then move the child nodes across into
30
// the target node
31
if (node.namespaceURI === DOMNamespaces.svg && !('innerHTML' in node)) {
32
- reusableSVGContainer = reusableSVGContainer ||
33
- document.createElement('div');
32
+ reusableSVGContainer =
33
+ reusableSVGContainer || document.createElement('div');
34
reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
35
var svgNode = reusableSVGContainer.firstChild;
36
while (svgNode.firstChild) {
src/renderers/dom/shared/syntheticEvents/SyntheticMouseEvent.js
+4
-2
@@ -34,10 +34,12 @@ var MouseEventInterface = {
34
button: null,
35
buttons: null,
36
relatedTarget: function(event) {
37
- return event.relatedTarget ||
37
+ return (
38
+ event.relatedTarget ||
39
(event.fromElement === event.srcElement
40
? event.toElement
40
- : event.fromElement);
41
+ : event.fromElement)
42
+ );
43
},
44
};
45
src/renderers/dom/shared/utils/ReactControlledValuePropTypes.js
+4
-1
@@ -46,7 +46,10 @@ var propTypes = {
46
},
47
checked: function(props, propName, componentName) {
48
if (
49
- !props[propName] || props.onChange || props.readOnly || props.disabled
49
+ !props[propName] ||
50
+ props.onChange ||
51
+ props.readOnly ||
52
+ props.disabled
53
) {
54
return null;
55
}
src/renderers/dom/shared/utils/isEventSupported.js
+2
-1
@@ -15,7 +15,8 @@ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
16
var useHasFeature;
17
if (ExecutionEnvironment.canUseDOM) {
18
- useHasFeature = document.implementation &&
18
+ useHasFeature =
19
+ document.implementation &&
20
document.implementation.hasFeature &&
21
// always returns true in newer browsers as per the standard.
22
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
src/renderers/dom/shared/validateDOMNesting.js
+34
-30
@@ -233,7 +233,6 @@ if (__DEV__) {
233
// but
234
case 'option':
235
return tag === '#text';
236
-
236
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
237
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
238
// No special behavior since these rules fall back to "in body" mode for
@@ -241,39 +240,42 @@ if (__DEV__) {
240
241
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
242
case 'tr':
244
- return tag === 'th' ||
243
+ return (
244
+ tag === 'th' ||
245
tag === 'td' ||
246
tag === 'style' ||
247
tag === 'script' ||
248
- tag === 'template';
249
-
248
+ tag === 'template'
249
+ );
250
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
251
case 'tbody':
252
case 'thead':
253
case 'tfoot':
254
- return tag === 'tr' ||
254
+ return (
255
+ tag === 'tr' ||
256
tag === 'style' ||
257
tag === 'script' ||
257
- tag === 'template';
258
-
258
+ tag === 'template'
259
+ );
260
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
261
case 'colgroup':
262
return tag === 'col' || tag === 'template';
262
-
263
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
264
case 'table':
265
- return tag === 'caption' ||
265
+ return (
266
+ tag === 'caption' ||
267
tag === 'colgroup' ||
268
tag === 'tbody' ||
269
tag === 'tfoot' ||
270
tag === 'thead' ||
271
tag === 'style' ||
272
tag === 'script' ||
272
- tag === 'template';
273
-
273
+ tag === 'template'
274
+ );
275
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
276
case 'head':
276
- return tag === 'base' ||
277
+ return (
278
+ tag === 'base' ||
279
tag === 'basefont' ||
280
tag === 'bgsound' ||
281
tag === 'link' ||
@@ -283,8 +285,8 @@ if (__DEV__) {
285
tag === 'noframes' ||
286
tag === 'style' ||
287
tag === 'script' ||
286
- tag === 'template';
287
-
288
+ tag === 'template'
289
+ );
290
// https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
291
case 'html':
292
return tag === 'head' || tag === 'body';
@@ -302,12 +304,14 @@ if (__DEV__) {
304
case 'h4':
305
case 'h5':
306
case 'h6':
305
- return parentTag !== 'h1' &&
307
+ return (
308
+ parentTag !== 'h1' &&
309
parentTag !== 'h2' &&
310
parentTag !== 'h3' &&
311
parentTag !== 'h4' &&
312
parentTag !== 'h5' &&
310
- parentTag !== 'h6';
313
+ parentTag !== 'h6'
314
+ );
315
316
case 'rp':
317
case 'rt':
@@ -428,8 +432,8 @@ if (__DEV__) {
432
isParent,
433
) {
434
var childOwner = childInstance && childInstance._currentElement._owner;
431
- var ancestorOwner = ancestorInstance &&
432
- ancestorInstance._currentElement._owner;
435
+ var ancestorOwner =
436
+ ancestorInstance && ancestorInstance._currentElement._owner;
437
438
var childOwners = findOwnerStack(childOwner);
439
var ancestorOwners = findOwnerStack(ancestorOwner);
@@ -508,7 +512,8 @@ if (__DEV__) {
512
var addendum;
513
514
if (childInstance != null) {
511
- addendum = ' See ' +
515
+ addendum =
516
+ ' See ' +
517
getOwnerInfo(
518
childInstance,
519
childTag,
@@ -521,13 +526,8 @@ if (__DEV__) {
526
addendum = getCurrentFiberStackAddendum();
527
}
528
524
- var warnKey = !!invalidParent +
525
- '|' +
526
- childTag +
527
- '|' +
528
- ancestorTag +
529
- '|' +
530
- addendum;
529
+ var warnKey =
530
+ !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum;
531
if (didWarn[warnKey]) {
532
return;
533
}
@@ -540,7 +540,8 @@ if (__DEV__) {
540
tagDisplayName = 'Text nodes';
541
} else {
542
tagDisplayName = 'Whitespace text nodes';
543
- whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " +
543
+ whitespaceInfo =
544
+ " Make sure you don't have any extra whitespace between tags on " +
545
'each line of your source code.';
546
}
547
} else {
@@ -550,7 +551,8 @@ if (__DEV__) {
551
if (invalidParent) {
552
var info = '';
553
if (ancestorTag === 'table' && childTag === 'tr') {
553
- info += ' Add a <tbody> to your code to match the DOM tree generated by ' +
554
+ info +=
555
+ ' Add a <tbody> to your code to match the DOM tree generated by ' +
556
'the browser.';
557
}
558
warning(
@@ -581,8 +583,10 @@ if (__DEV__) {
583
ancestorInfo = ancestorInfo || emptyAncestorInfo;
584
var parentInfo = ancestorInfo.current;
585
var parentTag = parentInfo && parentInfo.tag;
584
- return isTagValidWithParent(tag, parentTag) &&
585
- !findInvalidAncestorForTag(tag, ancestorInfo);
586
+ return (
587
+ isTagValidWithParent(tag, parentTag) &&
588
+ !findInvalidAncestorForTag(tag, ancestorInfo)
589
+ );
590
};
591
}
592
src/renderers/dom/shared/wrappers/__tests__/ReactDOMInput-test.js
+6
-6
@@ -100,12 +100,12 @@ describe('ReactDOMInput', () => {
100
<div>
101
<input
102
type="text"
103
- ref={n => this.a = n}
103
+ ref={n => (this.a = n)}
104
value={this.state.value}
105
onChange={e => this.change(e.target.value)}
106
onBlur={e => this.blur(e.target.value)}
107
/>
108
- <input type="text" ref={n => this.b = n} />
108
+ <input type="text" ref={n => (this.b = n)} />
109
</div>
110
);
111
}
@@ -151,11 +151,11 @@ describe('ReactDOMInput', () => {
151
<div>
152
<input
153
type="text"
154
- ref={n => this.a = n}
154
+ ref={n => (this.a = n)}
155
value="lion"
156
onChange={e => this.change(e.target.value)}
157
/>
158
- <input type="checkbox" ref={n => this.b = n} checked={true} />
158
+ <input type="checkbox" ref={n => (this.b = n)} checked={true} />
159
</div>
160
);
161
}
@@ -575,7 +575,7 @@ describe('ReactDOMInput', () => {
575
return (
576
<div>
577
<input
578
- ref={n => aNode = n}
578
+ ref={n => (aNode = n)}
579
type="radio"
580
name="fruit"
581
checked={true}
@@ -601,7 +601,7 @@ describe('ReactDOMInput', () => {
601
return (
602
<div>
603
<input
604
- ref={n => bNode = n}
604
+ ref={n => (bNode = n)}
605
type="radio"
606
name="fruit"
607
checked={false}
src/renderers/dom/stack/client/DOMChildrenOperations.js
+12
-11
@@ -37,14 +37,16 @@ function getNodeAfter(parentNode, node) {
37
* @param {number} index Index at which to insert the child.
38
* @internal
39
*/
40
-var insertChildAt = createMicrosoftUnsafeLocalFunction(
41
- function(parentNode, childNode, referenceNode) {
42
- // We rely exclusively on `insertBefore(node, null)` instead of also using
43
- // `appendChild(node)`. (Using `undefined` is not allowed by all browsers so
44
- // we are careful to use `null`.)
45
- parentNode.insertBefore(childNode, referenceNode);
46
- },
47
-);
40
+var insertChildAt = createMicrosoftUnsafeLocalFunction(function(
41
+ parentNode,
42
+ childNode,
43
+ referenceNode,
44
+) {
45
+ // We rely exclusively on `insertBefore(node, null)` instead of also using
46
+ // `appendChild(node)`. (Using `undefined` is not allowed by all browsers so
47
+ // we are careful to use `null`.)
48
+ parentNode.insertBefore(childNode, referenceNode);
49
+});
50
51
function insertLazyTreeChildAt(parentNode, childTree, referenceNode) {
52
DOMLazyTree.insertTreeBefore(parentNode, childTree, referenceNode);
@@ -123,9 +125,8 @@ function replaceDelimitedText(openingComment, closingComment, stringText) {
125
126
if (__DEV__) {
127
ReactInstrumentation.debugTool.onHostOperation({
126
- instanceID: ReactDOMComponentTree.getInstanceFromNode(
127
- openingComment,
128
- )._debugID,
128
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(openingComment)
129
+ ._debugID,
130
type: 'replace text',
131
payload: stringText,
132
});
src/renderers/dom/stack/client/DOMLazyTree.js
+28
-25
@@ -28,8 +28,9 @@ var setTextContent = require('setTextContent');
28
*
29
* See https://github.com/spicyj/innerhtml-vs-createelement-vs-clonenode.
30
*/
31
-var enableLazy = (typeof document !== 'undefined' &&
32
- typeof document.documentMode === 'number') ||
31
+var enableLazy =
32
+ (typeof document !== 'undefined' &&
33
+ typeof document.documentMode === 'number') ||
34
(typeof navigator !== 'undefined' &&
35
typeof navigator.userAgent === 'string' &&
36
/\bEdge\/\d/.test(navigator.userAgent));
@@ -51,29 +52,31 @@ function insertTreeChildren(tree) {
52
}
53
}
54
54
-var insertTreeBefore = createMicrosoftUnsafeLocalFunction(
55
- function(parentNode, tree, referenceNode) {
56
- // DocumentFragments aren't actually part of the DOM after insertion so
57
- // appending children won't update the DOM. We need to ensure the fragment
58
- // is properly populated first, breaking out of our lazy approach for just
59
- // this level. Also, some <object> plugins (like Flash Player) will read
60
- // <param> nodes immediately upon insertion into the DOM, so <object>
61
- // must also be populated prior to insertion into the DOM.
62
- if (
63
- tree.node.nodeType === DOCUMENT_FRAGMENT_NODE ||
64
- (tree.node.nodeType === ELEMENT_NODE &&
65
- tree.node.nodeName.toLowerCase() === 'object' &&
66
- (tree.node.namespaceURI == null ||
67
- tree.node.namespaceURI === DOMNamespaces.html))
68
- ) {
69
- insertTreeChildren(tree);
70
- parentNode.insertBefore(tree.node, referenceNode);
71
- } else {
72
- parentNode.insertBefore(tree.node, referenceNode);
73
- insertTreeChildren(tree);
74
- }
75
- },
76
-);
55
+var insertTreeBefore = createMicrosoftUnsafeLocalFunction(function(
56
+ parentNode,
57
+ tree,
58
+ referenceNode,
59
+) {
60
+ // DocumentFragments aren't actually part of the DOM after insertion so
61
+ // appending children won't update the DOM. We need to ensure the fragment
62
+ // is properly populated first, breaking out of our lazy approach for just
63
+ // this level. Also, some <object> plugins (like Flash Player) will read
64
+ // <param> nodes immediately upon insertion into the DOM, so <object>
65
+ // must also be populated prior to insertion into the DOM.
66
+ if (
67
+ tree.node.nodeType === DOCUMENT_FRAGMENT_NODE ||
68
+ (tree.node.nodeType === ELEMENT_NODE &&
69
+ tree.node.nodeName.toLowerCase() === 'object' &&
70
+ (tree.node.namespaceURI == null ||
71
+ tree.node.namespaceURI === DOMNamespaces.html))
72
+ ) {
73
+ insertTreeChildren(tree);
74
+ parentNode.insertBefore(tree.node, referenceNode);
75
+ } else {
76
+ parentNode.insertBefore(tree.node, referenceNode);
77
+ insertTreeChildren(tree);
78
+ }
79
+});
80
81
function replaceChildWithTree(oldNode, newTree) {
82
oldNode.parentNode.replaceChild(newTree.node, oldNode);
src/renderers/dom/stack/client/ReactDOMComponent.js
+6
-3
@@ -136,7 +136,8 @@ function ensureListeningTo(inst, registrationName, transaction) {
136
return;
137
}
138
var containerInfo = inst._hostContainerInfo;
139
- var isDocumentFragment = containerInfo._node &&
139
+ var isDocumentFragment =
140
+ containerInfo._node &&
141
containerInfo._node.nodeType === DOCUMENT_FRAGMENT_NODE;
142
var doc = isDocumentFragment
143
? containerInfo._node
@@ -1061,9 +1062,11 @@ ReactDOMComponent.Mixin = {
1062
? nextProps.children
1063
: null;
1064
1064
- var lastHtml = lastProps.dangerouslySetInnerHTML &&
1065
+ var lastHtml =
1066
+ lastProps.dangerouslySetInnerHTML &&
1067
lastProps.dangerouslySetInnerHTML.__html;
1066
- var nextHtml = nextProps.dangerouslySetInnerHTML &&
1068
+ var nextHtml =
1069
+ nextProps.dangerouslySetInnerHTML &&
1070
nextProps.dangerouslySetInnerHTML.__html;
1071
1072
// Note the use of `!=` which checks for null or undefined.
src/renderers/dom/stack/client/ReactDOMStackInjection.js
+5
-5
@@ -46,11 +46,11 @@ function inject() {
46
47
ReactHostComponent.injection.injectTextComponentClass(ReactDOMTextComponent);
48
49
- ReactEmptyComponent.injection.injectEmptyComponentFactory(
50
- function(instantiate) {
51
- return new ReactDOMEmptyComponent(instantiate);
52
- },
53
- );
49
+ ReactEmptyComponent.injection.injectEmptyComponentFactory(function(
50
+ instantiate,
51
+ ) {
52
+ return new ReactDOMEmptyComponent(instantiate);
53
+ });
54
55
ReactUpdates.injection.injectReconcileTransaction(ReactReconcileTransaction);
56
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
src/renderers/dom/stack/client/ReactDOMTextComponent.js
+6
-3
@@ -110,13 +110,15 @@ Object.assign(ReactDOMTextComponent.prototype, {
110
return escapedText;
111
}
112
113
- return '<!--' +
113
+ return (
114
+ '<!--' +
115
openingValue +
116
'-->' +
117
escapedText +
118
'<!--' +
119
closingValue +
119
- '-->';
120
+ '-->'
121
+ );
122
}
123
},
124
@@ -161,7 +163,8 @@ Object.assign(ReactDOMTextComponent.prototype, {
163
this._domID,
164
);
165
if (
164
- node.nodeType === COMMENT_NODE && node.nodeValue === ' /react-text '
166
+ node.nodeType === COMMENT_NODE &&
167
+ node.nodeValue === ' /react-text '
168
) {
169
this._closingComment = node;
170
break;
src/renderers/dom/stack/client/ReactMount.js
+22
-13
@@ -103,7 +103,8 @@ function mountComponentIntoNode(
103
if (ReactFeatureFlags.logTopLevelRenders) {
104
var wrappedElement = wrapperInstance._currentElement.props.child;
105
var type = wrappedElement.type;
106
- markerName = 'React mount: ' +
106
+ markerName =
107
+ 'React mount: ' +
108
(typeof type === 'string' ? type : type.displayName || type.name);
109
console.time(markerName);
110
}
@@ -247,14 +248,16 @@ function isValidContainer(node) {
248
* @internal
249
*/
250
function isReactNode(node) {
250
- return isValidContainer(node) &&
251
- (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
251
+ return (
252
+ isValidContainer(node) &&
253
+ (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME))
254
+ );
255
}
256
257
function getHostRootInstanceInContainer(container) {
258
var rootEl = getReactRootElementInContainer(container);
256
- var prevHostInstance = rootEl &&
257
- ReactDOMComponentTree.getInstanceFromNode(rootEl);
259
+ var prevHostInstance =
260
+ rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl);
261
return prevHostInstance && !prevHostInstance._hostParent
262
? prevHostInstance
263
: null;
@@ -475,7 +478,8 @@ var ReactMount = {
478
'or <Foo />.',
479
);
480
} else if (
478
- nextElement != null && typeof nextElement.props !== 'undefined'
481
+ nextElement != null &&
482
+ typeof nextElement.props !== 'undefined'
483
) {
484
// Check if it quacks like an element
485
invariant(
@@ -512,7 +516,8 @@ var ReactMount = {
516
var prevElement = prevWrappedElement.props.child;
517
if (shouldUpdateReactComponent(prevElement, nextElement)) {
518
var publicInst = prevComponent._renderedComponent.getPublicInstance();
515
- var updatedCallback = callback &&
519
+ var updatedCallback =
520
+ callback &&
521
function() {
522
validateCallback(callback);
523
callback.call(publicInst);
@@ -531,8 +536,8 @@ var ReactMount = {
536
}
537
538
var reactRootElement = getReactRootElementInContainer(container);
534
- var containerHasReactMarkup = reactRootElement &&
535
- !!internalGetID(reactRootElement);
539
+ var containerHasReactMarkup =
540
+ reactRootElement && !!internalGetID(reactRootElement);
541
var containerHasNonRootReactChild = hasNonRootReactChild(container);
542
543
if (__DEV__) {
@@ -561,7 +566,8 @@ var ReactMount = {
566
}
567
}
568
564
- var shouldReuseMarkup = containerHasReactMarkup &&
569
+ var shouldReuseMarkup =
570
+ containerHasReactMarkup &&
571
!prevComponent &&
572
!containerHasNonRootReactChild;
573
var component = ReactMount._renderNewRootComponent(
@@ -639,7 +645,8 @@ var ReactMount = {
645
var containerHasNonRootReactChild = hasNonRootReactChild(container);
646
647
// Check if the container itself is a React root node.
642
- var isContainerReactRoot = container.nodeType === ELEMENT_NODE &&
648
+ var isContainerReactRoot =
649
+ container.nodeType === ELEMENT_NODE &&
650
container.hasAttribute(ROOT_ATTR_NAME);
651
652
if (__DEV__) {
@@ -710,13 +717,15 @@ var ReactMount = {
717
normalizer = document.createElement('iframe');
718
document.body.appendChild(normalizer);
719
normalizer.contentDocument.write(markup);
713
- normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
720
+ normalizedMarkup =
721
+ normalizer.contentDocument.documentElement.outerHTML;
722
document.body.removeChild(normalizer);
723
}
724
}
725
726
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
719
- var difference = ' (client) ' +
727
+ var difference =
728
+ ' (client) ' +
729
normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) +
730
'\n (server) ' +
731
rootMarkup.substring(diffIndex - 20, diffIndex + 20);
src/renderers/dom/stack/client/wrappers/ReactDOMInput.js
+2
-1
@@ -84,7 +84,8 @@ var ReactDOMInput = {
84
if (__DEV__) {
85
var owner = inst._currentElement._owner;
86
ReactControlledValuePropTypes.checkPropTypes('input', props, () =>
87
- getStackAddendumByID(inst._debugID));
87
+ getStackAddendumByID(inst._debugID),
88
+ );
89
90
if (
91
props.checked !== undefined &&
src/renderers/dom/stack/client/wrappers/ReactDOMSelect.js
+2
-1
@@ -43,7 +43,8 @@ var valuePropNames = ['value', 'defaultValue'];
43
function checkSelectPropTypes(inst, props) {
44
var owner = inst._currentElement._owner;
45
ReactControlledValuePropTypes.checkPropTypes('select', props, () =>
46
- getStackAddendumByID(inst._debugID));
46
+ getStackAddendumByID(inst._debugID),
47
+ );
48
49
for (var i = 0; i < valuePropNames.length; i++) {
50
var propName = valuePropNames[i];
src/renderers/dom/stack/client/wrappers/ReactDOMTextarea.js
+2
-1
@@ -64,7 +64,8 @@ var ReactDOMTextarea = {
64
mountWrapper: function(inst, props) {
65
if (__DEV__) {
66
ReactControlledValuePropTypes.checkPropTypes('textarea', props, () =>
67
- getStackAddendumByID(inst._debugID));
67
+ getStackAddendumByID(inst._debugID),
68
+ );
69
if (
70
props.value !== undefined &&
71
props.defaultValue !== undefined &&
src/renderers/dom/stack/server/ReactServerRendering.js
+19
-22
@@ -40,29 +40,26 @@ function renderToStringImpl(element, makeStaticMarkup) {
40
41
pendingTransactions++;
42
43
- return transaction.perform(
44
- function() {
45
- var componentInstance = instantiateReactComponent(element, true);
46
- var markup = ReactReconciler.mountComponent(
47
- componentInstance,
48
- transaction,
49
- null,
50
- ReactDOMContainerInfo(),
51
- emptyObject,
52
- 0 /* parentDebugID */,
43
+ return transaction.perform(function() {
44
+ var componentInstance = instantiateReactComponent(element, true);
45
+ var markup = ReactReconciler.mountComponent(
46
+ componentInstance,
47
+ transaction,
48
+ null,
49
+ ReactDOMContainerInfo(),
50
+ emptyObject,
51
+ 0 /* parentDebugID */,
52
+ );
53
+ if (__DEV__) {
54
+ ReactInstrumentation.debugTool.onUnmountComponent(
55
+ componentInstance._debugID,
56
);
54
- if (__DEV__) {
55
- ReactInstrumentation.debugTool.onUnmountComponent(
56
- componentInstance._debugID,
57
- );
58
- }
59
- if (!makeStaticMarkup) {
60
- markup = ReactMarkupChecksum.addChecksumToMarkup(markup);
61
- }
62
- return markup;
63
- },
64
- null,
65
- );
57
+ }
58
+ if (!makeStaticMarkup) {
59
+ markup = ReactMarkupChecksum.addChecksumToMarkup(markup);
60
+ }
61
+ return markup;
62
+ }, null);
63
} finally {
64
pendingTransactions--;
65
ReactServerRenderingTransaction.release(transaction);
src/renderers/dom/test/ReactTestUtils.js
+14
-9
@@ -175,9 +175,11 @@ var ReactTestUtils = {
175
// this returns when we have DOM nodes as refs directly
176
return false;
177
}
178
- return inst != null &&
178
+ return (
179
+ inst != null &&
180
typeof inst.render === 'function' &&
180
- typeof inst.setState === 'function';
181
+ typeof inst.setState === 'function'
182
+ );
183
},
184
185
isCompositeComponentWithType: function(inst, type) {
@@ -200,8 +202,10 @@ var ReactTestUtils = {
202
// We check the prototype of the type that will get mounted, not the
203
// instance itself. This is a future proof way of duck typing.
204
var prototype = inst.type.prototype;
203
- return typeof prototype.render === 'function' &&
204
- typeof prototype.setState === 'function';
205
+ return (
206
+ typeof prototype.render === 'function' &&
207
+ typeof prototype.setState === 'function'
208
+ );
209
},
210
211
// TODO: deprecate? It's undocumented and unused.
@@ -299,8 +303,10 @@ var ReactTestUtils = {
303
*/
304
scryRenderedDOMComponentsWithTag: function(root, tagName) {
305
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
302
- return ReactTestUtils.isDOMComponent(inst) &&
303
- inst.tagName.toUpperCase() === tagName.toUpperCase();
306
+ return (
307
+ ReactTestUtils.isDOMComponent(inst) &&
308
+ inst.tagName.toUpperCase() === tagName.toUpperCase()
309
+ );
310
});
311
},
312
@@ -450,9 +456,8 @@ function makeSimulator(eventType) {
456
node = domComponentOrNode;
457
}
458
453
- var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[
454
- eventType
455
- ];
459
+ var dispatchConfig =
460
+ EventPluginRegistry.eventNameDispatchConfigs[eventType];
461
462
var fakeNativeEvent = new Event();
463
fakeNativeEvent.target = node;
src/renderers/native/NativeMethodsMixin.js
+2
-1
@@ -176,7 +176,8 @@ function setNativePropsFiber(componentOrHandle: any, nativeProps: Object) {
176
return;
177
}
178
179
- const viewConfig: ReactNativeBaseComponentViewConfig = maybeInstance.viewConfig;
179
+ const viewConfig: ReactNativeBaseComponentViewConfig =
180
+ maybeInstance.viewConfig;
181
182
if (__DEV__) {
183
warnForStyleProps(nativeProps, viewConfig.validAttributes);
src/renderers/native/NativeMethodsMixinUtils.js
+4
-2
@@ -71,12 +71,14 @@ function throwOnStylesProp(component: any, props: any) {
71
if (props.styles !== undefined) {
72
var owner = component._owner || null;
73
var name = component.constructor.displayName;
74
- var msg = '`styles` is not a supported property of `' +
74
+ var msg =
75
+ '`styles` is not a supported property of `' +
76
name +
77
'`, did ' +
78
'you mean `style` (singular)?';
79
if (owner && owner.constructor && owner.constructor.displayName) {
79
- msg += '\n\nCheck the `' +
80
+ msg +=
81
+ '\n\nCheck the `' +
82
owner.constructor.displayName +
83
'` parent ' +
84
' component.';
src/renderers/native/ReactNativeAttributePayload.js
+2
-1
@@ -377,7 +377,8 @@ function diffProperties(
377
typeof attributeConfig.process === 'function'
378
) {
379
// case: CustomAttributeConfiguration
380
- var shouldUpdate = prevProp === undefined ||
380
+ var shouldUpdate =
381
+ prevProp === undefined ||
382
(typeof attributeConfig.diff === 'function'
383
? attributeConfig.diff(prevProp, nextProp)
384
: defaultDiffer(prevProp, nextProp));
src/renderers/native/ReactNativeBridgeEventPlugin.js
+2
-3
@@ -23,9 +23,8 @@ var customDirectEventTypes = UIManager.customDirectEventTypes;
23
var allTypesByEventName = {};
24
25
for (var bubblingTypeName in customBubblingEventTypes) {
26
- allTypesByEventName[bubblingTypeName] = customBubblingEventTypes[
27
- bubblingTypeName
28
- ];
26
+ allTypesByEventName[bubblingTypeName] =
27
+ customBubblingEventTypes[bubblingTypeName];
28
}
29
30
for (var directTypeName in customDirectEventTypes) {
src/renderers/native/ReactNativeFiber.js
+4
-3
@@ -239,9 +239,9 @@ const NativeRenderer = ReactFiberReconciler({
239
// Either way we need to pass a copy of the Array to prevent it from being frozen.
240
const nativeTags = parentInstance._children.map(
241
child =>
242
- typeof child === 'number'
242
+ (typeof child === 'number'
243
? child // Leaf node (eg text)
244
- : child._nativeTag,
244
+ : child._nativeTag),
245
);
246
247
UIManager.setChildren(
@@ -396,7 +396,8 @@ ReactGenericBatching.injection.injectFiberBatchedUpdates(
396
const roots = new Map();
397
398
findNodeHandle.injection.injectFindNode((fiber: Fiber) =>
399
- NativeRenderer.findHostInstance(fiber));
399
+ NativeRenderer.findHostInstance(fiber),
400
+);
401
findNodeHandle.injection.injectFindRootNodeID(instance => instance);
402
403
// Intercept lifecycle errors and ensure they are shown with the correct stack
src/renderers/native/ReactNativeFiberHostComponent.js
+1
-4
@@ -17,10 +17,7 @@ var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
17
var TextInputState = require('TextInputState');
18
var UIManager = require('UIManager');
19
20
-var {
21
- mountSafeCallback,
22
- warnForStyleProps,
23
-} = require('NativeMethodsMixinUtils');
20
+var {mountSafeCallback, warnForStyleProps} = require('NativeMethodsMixinUtils');
21
22
import type {
23
MeasureInWindowOnSuccessCallback,
src/renderers/native/__tests__/ReactNativeMount-test.js
+1
-1
@@ -69,7 +69,7 @@ describe('ReactNative', () => {
69
var a;
70
var b;
71
var c = ReactNative.render(
72
- <View foo="foo" ref={v => a = v} />,
72
+ <View foo="foo" ref={v => (a = v)} />,
73
11,
74
function() {
75
b = this;
src/renderers/noop/ReactNoop.js
+4
-5
@@ -25,9 +25,7 @@ import type {UpdateQueue} from 'ReactFiberUpdateQueue';
25
var ReactFiberInstrumentation = require('ReactFiberInstrumentation');
26
var ReactFiberReconciler = require('ReactFiberReconciler');
27
var ReactInstanceMap = require('ReactInstanceMap');
28
-var {
29
- AnimationPriority,
30
-} = require('ReactPriorityLevel');
28
+var {AnimationPriority} = require('ReactPriorityLevel');
29
var emptyObject = require('fbjs/lib/emptyObject');
30
31
const UPDATE_SIGNAL = {};
@@ -116,8 +114,9 @@ var NoopRenderer = ReactFiberReconciler({
114
},
115
116
shouldSetTextContent(props: Props): boolean {
119
- return typeof props.children === 'string' ||
120
- typeof props.children === 'number';
117
+ return (
118
+ typeof props.children === 'string' || typeof props.children === 'number'
119
+ );
120
},
121
122
resetTextContent(instance: Instance): void {},
src/renderers/shared/ReactDOMFrameScheduling.js
+2
-1
@@ -84,7 +84,8 @@ if (typeof requestAnimationFrame !== 'function') {
84
isAnimationFrameScheduled = false;
85
var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
86
if (
87
- nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime
87
+ nextFrameTime < activeFrameTime &&
88
+ previousFrameTime < activeFrameTime
89
) {
90
if (nextFrameTime < 8) {
91
// Defensive coding. We don't support higher frame rates than 120hz.
src/renderers/shared/ReactDebugTool.js
+20
-22
@@ -113,25 +113,22 @@ if (__DEV__) {
113
};
114
115
const getTreeSnapshot = function(registeredIDs) {
116
- return registeredIDs.reduce(
117
- (tree, id) => {
118
- var ownerID = ReactComponentTreeHook.getOwnerID(id);
119
- var parentID = ReactComponentTreeHook.getParentID(id);
120
- tree[id] = {
121
- displayName: ReactComponentTreeHook.getDisplayName(id),
122
- text: ReactComponentTreeHook.getText(id),
123
- updateCount: ReactComponentTreeHook.getUpdateCount(id),
124
- childIDs: ReactComponentTreeHook.getChildIDs(id),
125
- // Text nodes don't have owners but this is close enough.
126
- ownerID: ownerID ||
127
- (parentID && ReactComponentTreeHook.getOwnerID(parentID)) ||
128
- 0,
129
- parentID,
130
- };
131
- return tree;
132
- },
133
- {},
134
- );
116
+ return registeredIDs.reduce((tree, id) => {
117
+ var ownerID = ReactComponentTreeHook.getOwnerID(id);
118
+ var parentID = ReactComponentTreeHook.getParentID(id);
119
+ tree[id] = {
120
+ displayName: ReactComponentTreeHook.getDisplayName(id),
121
+ text: ReactComponentTreeHook.getText(id),
122
+ updateCount: ReactComponentTreeHook.getUpdateCount(id),
123
+ childIDs: ReactComponentTreeHook.getChildIDs(id),
124
+ // Text nodes don't have owners but this is close enough.
125
+ ownerID: ownerID ||
126
+ (parentID && ReactComponentTreeHook.getOwnerID(parentID)) ||
127
+ 0,
128
+ parentID,
129
+ };
130
+ return tree;
131
+ }, {});
132
};
133
134
const resetMeasurements = function() {
@@ -252,7 +249,8 @@ if (__DEV__) {
249
};
250
251
var lastMarkTimeStamp = 0;
255
- var canUsePerformanceMeasure: boolean = typeof performance !== 'undefined' &&
252
+ var canUsePerformanceMeasure: boolean =
253
+ typeof performance !== 'undefined' &&
254
typeof performance.mark === 'function' &&
255
typeof performance.clearMarks === 'function' &&
256
typeof performance.measure === 'function' &&
@@ -289,8 +287,8 @@ if (__DEV__) {
287
}
288
289
var markName = `${debugID}::${markType}`;
292
- var displayName = ReactComponentTreeHook.getDisplayName(debugID) ||
293
- 'Unknown';
290
+ var displayName =
291
+ ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';
292
293
// Chrome has an issue of dropping markers recorded too fast:
294
// https://bugs.chromium.org/p/chromium/issues/detail?id=640652
src/renderers/shared/ReactGlobalSharedState.js
+2
-1
@@ -11,7 +11,8 @@
11
12
'use strict';
13
14
-var ReactInternals = require('react').__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
14
+var ReactInternals = require('react')
15
+ .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
16
17
var ReactGlobalSharedState = {
18
ReactCurrentOwner: ReactInternals.ReactCurrentOwner,
src/renderers/shared/ReactPerf.js
+8
-7
@@ -71,13 +71,13 @@ function getExclusive(flushHistory = getLastMeasurements()) {
71
var stats = aggregatedStats[key];
72
if (!stats) {
73
affectedIDs[key] = {};
74
- stats = (aggregatedStats[key] = {
74
+ stats = aggregatedStats[key] = {
75
key,
76
instanceCount: 0,
77
counts: {},
78
durations: {},
79
totalDuration: 0,
80
- });
80
+ };
81
}
82
if (!stats.durations[timerType]) {
83
stats.durations[timerType] = 0;
@@ -125,12 +125,12 @@ function getInclusive(flushHistory = getLastMeasurements()) {
125
var stats = aggregatedStats[key];
126
if (!stats) {
127
affectedIDs[key] = {};
128
- stats = (aggregatedStats[key] = {
128
+ stats = aggregatedStats[key] = {
129
key,
130
instanceCount: 0,
131
inclusiveRenderDuration: 0,
132
renderCount: 0,
133
- });
133
+ };
134
}
135
affectedIDs[key][instanceID] = true;
136
applyUpdate(stats);
@@ -196,12 +196,12 @@ function getWasted(flushHistory = getLastMeasurements()) {
196
var stats = aggregatedStats[key];
197
if (!stats) {
198
affectedIDs[key] = {};
199
- stats = (aggregatedStats[key] = {
199
+ stats = aggregatedStats[key] = {
200
key,
201
instanceCount: 0,
202
inclusiveRenderDuration: 0,
203
renderCount: 0,
204
- });
204
+ };
205
}
206
affectedIDs[key][instanceID] = true;
207
applyUpdate(stats);
@@ -255,7 +255,8 @@ function getWasted(flushHistory = getLastMeasurements()) {
255
while (nextParentID) {
256
// Any parents rendered during this batch are considered wasted
257
// unless we previously marked them as dirty.
258
- var isWasted = renderedCompositeIDs[nextParentID] &&
258
+ var isWasted =
259
+ renderedCompositeIDs[nextParentID] &&
260
!isDefinitelyNotWastedByID[nextParentID];
261
if (isWasted) {
262
updateAggregatedStats(treeSnapshot, nextParentID, stats => {
src/renderers/shared/fiber/ReactChildFiber.js
+24
-27
@@ -20,13 +20,8 @@ import type {ReactInstance} from 'ReactInstanceType';
20
import type {PriorityLevel} from 'ReactPriorityLevel';
21
22
var REACT_ELEMENT_TYPE = require('ReactElementSymbol');
23
-var {
24
- REACT_COROUTINE_TYPE,
25
- REACT_YIELD_TYPE,
26
-} = require('ReactCoroutine');
27
-var {
28
- REACT_PORTAL_TYPE,
29
-} = require('ReactPortal');
23
+var {REACT_COROUTINE_TYPE, REACT_YIELD_TYPE} = require('ReactCoroutine');
24
+var {REACT_PORTAL_TYPE} = require('ReactPortal');
25
26
var ReactFiber = require('ReactFiber');
27
var ReactTypeOfSideEffect = require('ReactTypeOfSideEffect');
@@ -61,7 +56,8 @@ if (__DEV__) {
56
);
57
child._store.validated = true;
58
64
- var currentComponentErrorInfo = 'Each child in an array or iterator should have a unique ' +
59
+ var currentComponentErrorInfo =
60
+ 'Each child in an array or iterator should have a unique ' +
61
'"key" prop. See https://fb.me/react-warning-keys for ' +
62
'more information.' +
63
(getCurrentFiberStackAddendum(child) || '');
@@ -102,11 +98,7 @@ const {
98
Fragment,
99
} = ReactTypeOfWork;
100
105
-const {
106
- NoEffect,
107
- Placement,
108
- Deletion,
109
-} = ReactTypeOfSideEffect;
101
+const {NoEffect, Placement, Deletion} = ReactTypeOfSideEffect;
102
103
function coerceRef(current: Fiber | null, element: ReactElement) {
104
let mixedRef = element.ref;
@@ -161,7 +153,8 @@ function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) {
153
if (returnFiber.type !== 'textarea') {
154
let addendum = '';
155
if (__DEV__) {
164
- addendum = ' If you meant to render a collection of children, use an array ' +
156
+ addendum =
157
+ ' If you meant to render a collection of children, use an array ' +
158
'instead.' +
159
(getCurrentFiberStackAddendum() || '');
160
}
@@ -201,7 +194,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
194
last.nextEffect = childToDelete;
195
returnFiber.progressedLastDeletion = childToDelete;
196
} else {
204
- returnFiber.progressedFirstDeletion = (returnFiber.progressedLastDeletion = childToDelete);
197
+ returnFiber.progressedFirstDeletion = returnFiber.progressedLastDeletion = childToDelete;
198
}
199
childToDelete.nextEffect = null;
200
childToDelete.effectTag = Deletion;
@@ -582,16 +575,18 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
575
if (typeof newChild === 'object' && newChild !== null) {
576
switch (newChild.$$typeof) {
577
case REACT_ELEMENT_TYPE: {
585
- const matchedFiber = existingChildren.get(
586
- newChild.key === null ? newIdx : newChild.key,
587
- ) || null;
578
+ const matchedFiber =
579
+ existingChildren.get(
580
+ newChild.key === null ? newIdx : newChild.key,
581
+ ) || null;
582
return updateElement(returnFiber, matchedFiber, newChild, priority);
583
}
584
585
case REACT_COROUTINE_TYPE: {
592
- const matchedFiber = existingChildren.get(
593
- newChild.key === null ? newIdx : newChild.key,
594
- ) || null;
586
+ const matchedFiber =
587
+ existingChildren.get(
588
+ newChild.key === null ? newIdx : newChild.key,
589
+ ) || null;
590
return updateCoroutine(returnFiber, matchedFiber, newChild, priority);
591
}
592
@@ -603,9 +598,10 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
598
}
599
600
case REACT_PORTAL_TYPE: {
606
- const matchedFiber = existingChildren.get(
607
- newChild.key === null ? newIdx : newChild.key,
608
- ) || null;
601
+ const matchedFiber =
602
+ existingChildren.get(
603
+ newChild.key === null ? newIdx : newChild.key,
604
+ ) || null;
605
return updatePortal(returnFiber, matchedFiber, newChild, priority);
606
}
607
}
@@ -1251,7 +1247,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
1247
if (__DEV__) {
1248
const instance = returnFiber.stateNode;
1249
if (
1254
- instance.render._isMockFunction && typeof newChild === 'undefined'
1250
+ instance.render._isMockFunction &&
1251
+ typeof newChild === 'undefined'
1252
) {
1253
// We allow auto-mocks to proceed as if they're
1254
// returning null.
@@ -1384,10 +1381,10 @@ exports.cloneChildFibers = function(
1381
newChild.return = workInProgress;
1382
while (currentChild.sibling !== null) {
1383
currentChild = currentChild.sibling;
1387
- newChild = (newChild.sibling = cloneFiber(
1384
+ newChild = newChild.sibling = cloneFiber(
1385
currentChild,
1386
currentChild.pendingWorkPriority,
1390
- ));
1387
+ );
1388
newChild.return = workInProgress;
1389
}
1390
newChild.sibling = null;
src/renderers/shared/fiber/ReactDebugFiberPerf.js
+2
-1
@@ -41,7 +41,8 @@ if (__DEV__) {
41
// Longer prefixes are hard to read in DevTools.
42
const reactEmoji = '\u269B';
43
const warningEmoji = '\u26D4';
44
- const supportsUserTiming = typeof performance !== 'undefined' &&
44
+ const supportsUserTiming =
45
+ typeof performance !== 'undefined' &&
46
typeof performance.mark === 'function' &&
47
typeof performance.clearMarks === 'function' &&
48
typeof performance.measure === 'function' &&
src/renderers/shared/fiber/ReactFiber.js
+8
-11
@@ -35,17 +35,11 @@ var {
35
Fragment,
36
} = ReactTypeOfWork;
37
38
-var {
39
- NoWork,
40
-} = require('ReactPriorityLevel');
38
+var {NoWork} = require('ReactPriorityLevel');
39
42
-var {
43
- NoEffect,
44
-} = require('ReactTypeOfSideEffect');
40
+var {NoEffect} = require('ReactTypeOfSideEffect');
41
46
-var {
47
- cloneUpdateQueue,
48
-} = require('ReactFiberUpdateQueue');
42
+var {cloneUpdateQueue} = require('ReactFiberUpdateQueue');
43
44
var invariant = require('fbjs/lib/invariant');
45
@@ -360,7 +354,9 @@ function createFiberFromElementType(
354
fiber = createFiber(HostComponent, key);
355
fiber.type = type;
356
} else if (
363
- typeof type === 'object' && type !== null && typeof type.tag === 'number'
357
+ typeof type === 'object' &&
358
+ type !== null &&
359
+ typeof type.tag === 'number'
360
) {
361
// Currently assumed to be a continuation and therefore is a fiber already.
362
// TODO: The yield system is currently broken for updates in some cases.
@@ -378,7 +374,8 @@ function createFiberFromElementType(
374
type !== null &&
375
Object.keys(type).length === 0)
376
) {
381
- info += ' You likely forgot to export your component from the file ' +
377
+ info +=
378
+ ' You likely forgot to export your component from the file ' +
379
"it's defined in.";
380
}
381
const ownerName = debugOwner ? getComponentName(debugOwner) : null;
src/renderers/shared/fiber/ReactFiberBeginWork.js
+11
-21
@@ -25,9 +25,7 @@ var {
25
reconcileChildFibersInPlace,
26
cloneChildFibers,
27
} = require('ReactChildFiber');
28
-var {
29
- beginUpdateQueue,
30
-} = require('ReactFiberUpdateQueue');
28
+var {beginUpdateQueue} = require('ReactFiberUpdateQueue');
29
var ReactTypeOfWork = require('ReactTypeOfWork');
30
var {
31
getMaskedContext,
@@ -50,16 +48,8 @@ var {
48
YieldComponent,
49
Fragment,
50
} = ReactTypeOfWork;
53
-var {
54
- NoWork,
55
- OffscreenPriority,
56
-} = require('ReactPriorityLevel');
57
-var {
58
- Placement,
59
- ContentReset,
60
- Err,
61
- Ref,
62
-} = require('ReactTypeOfSideEffect');
51
+var {NoWork, OffscreenPriority} = require('ReactPriorityLevel');
52
+var {Placement, ContentReset, Err, Ref} = require('ReactTypeOfSideEffect');
53
var ReactFiberClassComponent = require('ReactFiberClassComponent');
54
var {ReactCurrentOwner} = require('ReactGlobalSharedState');
55
var invariant = require('fbjs/lib/invariant');
@@ -84,10 +74,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
74
shouldDeprioritizeSubtree,
75
} = config;
76
87
- const {
88
- pushHostContext,
89
- pushHostContainer,
90
- } = hostContext;
77
+ const {pushHostContext, pushHostContainer} = hostContext;
78
79
const {
80
adoptClassInstance,
@@ -115,7 +102,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
102
}
103
104
function clearDeletions(workInProgress) {
118
- workInProgress.progressedFirstDeletion = (workInProgress.progressedLastDeletion = null);
105
+ workInProgress.progressedFirstDeletion = workInProgress.progressedLastDeletion = null;
106
}
107
108
function transferDeletions(workInProgress) {
@@ -196,7 +183,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
183
nextChildren = workInProgress.memoizedProps;
184
}
185
} else if (
199
- nextChildren === null || workInProgress.memoizedProps === nextChildren
186
+ nextChildren === null ||
187
+ workInProgress.memoizedProps === nextChildren
188
) {
189
return bailoutOnAlreadyFinishedWork(current, workInProgress);
190
}
@@ -585,7 +573,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
573
);
574
}
575
} else if (
588
- nextCoroutine === null || workInProgress.memoizedProps === nextCoroutine
576
+ nextCoroutine === null ||
577
+ workInProgress.memoizedProps === nextCoroutine
578
) {
579
nextCoroutine = workInProgress.memoizedProps;
580
// TODO: When bailing out, we might need to return the stateNode instead
@@ -653,7 +642,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
642
);
643
}
644
} else if (
656
- nextChildren === null || workInProgress.memoizedProps === nextChildren
645
+ nextChildren === null ||
646
+ workInProgress.memoizedProps === nextChildren
647
) {
648
return bailoutOnAlreadyFinishedWork(current, workInProgress);
649
}
src/renderers/shared/fiber/ReactFiberClassComponent.js
+16
-18
@@ -15,9 +15,7 @@
15
import type {Fiber} from 'ReactFiber';
16
import type {PriorityLevel} from 'ReactPriorityLevel';
17
18
-var {
19
- Update,
20
-} = require('ReactTypeOfSideEffect');
18
+var {Update} = require('ReactTypeOfSideEffect');
19
var {
20
cacheContext,
21
getMaskedContext,
@@ -41,10 +39,7 @@ var invariant = require('fbjs/lib/invariant');
39
const isArray = Array.isArray;
40
41
if (__DEV__) {
44
- var {
45
- startPhaseTimer,
46
- stopPhaseTimer,
47
- } = require('ReactDebugFiberPerf');
42
+ var {startPhaseTimer, stopPhaseTimer} = require('ReactDebugFiberPerf');
43
var warning = require('fbjs/lib/warning');
44
var warnOnInvalidCallback = function(callback: mixed, callerName: string) {
45
warning(
@@ -143,8 +138,9 @@ module.exports = function(
138
139
const type = workInProgress.type;
140
if (type.prototype && type.prototype.isPureReactComponent) {
146
- return !shallowEqual(oldProps, newProps) ||
147
- !shallowEqual(oldState, newState);
141
+ return (
142
+ !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState)
143
+ );
144
}
145
146
return true;
@@ -161,7 +157,8 @@ module.exports = function(
157
'instance: you may have forgotten to define `render`.',
158
name,
159
);
164
- const noGetInitialStateOnES6 = !instance.getInitialState ||
160
+ const noGetInitialStateOnES6 =
161
+ !instance.getInitialState ||
162
instance.getInitialState.isReactClassApproved ||
163
instance.state;
164
warning(
@@ -171,7 +168,8 @@ module.exports = function(
168
'Did you mean to define a state property instead?',
169
name,
170
);
174
- const noGetDefaultPropsOnES6 = !instance.getDefaultProps ||
171
+ const noGetDefaultPropsOnES6 =
172
+ !instance.getDefaultProps ||
173
instance.getDefaultProps.isReactClassApproved;
174
warning(
175
noGetDefaultPropsOnES6,
@@ -194,8 +192,8 @@ module.exports = function(
192
'property to define contextTypes instead.',
193
name,
194
);
197
- const noComponentShouldUpdate = typeof instance.componentShouldUpdate !==
198
- 'function';
195
+ const noComponentShouldUpdate =
196
+ typeof instance.componentShouldUpdate !== 'function';
197
warning(
198
noComponentShouldUpdate,
199
'%s has a method called ' +
@@ -204,8 +202,8 @@ module.exports = function(
202
'expected to return a value.',
203
name,
204
);
207
- const noComponentDidUnmount = typeof instance.componentDidUnmount !==
208
- 'function';
205
+ const noComponentDidUnmount =
206
+ typeof instance.componentDidUnmount !== 'function';
207
warning(
208
noComponentDidUnmount,
209
'%s has a method called ' +
@@ -213,8 +211,8 @@ module.exports = function(
211
'Did you mean componentWillUnmount()?',
212
name,
213
);
216
- const noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !==
217
- 'function';
214
+ const noComponentWillRecieveProps =
215
+ typeof instance.componentWillRecieveProps !== 'function';
216
warning(
217
noComponentWillRecieveProps,
218
'%s has a method called ' +
@@ -381,7 +379,7 @@ module.exports = function(
379
// want to reuse one that failed to fully mount.
380
const newInstance = constructClassInstance(workInProgress);
381
newInstance.props = newProps;
384
- newInstance.state = (newState = newInstance.state || null);
382
+ newInstance.state = newState = newInstance.state || null;
383
newInstance.context = newContext;
384
385
if (typeof newInstance.componentWillMount === 'function') {
src/renderers/shared/fiber/ReactFiberCommitWork.js
+7
-7
@@ -38,10 +38,7 @@ var {
38
var invariant = require('fbjs/lib/invariant');
39
40
if (__DEV__) {
41
- var {
42
- startPhaseTimer,
43
- stopPhaseTimer,
44
- } = require('ReactDebugFiberPerf');
41
+ var {startPhaseTimer, stopPhaseTimer} = require('ReactDebugFiberPerf');
42
}
43
44
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
@@ -143,9 +140,11 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
140
}
141
142
function isHostParent(fiber: Fiber): boolean {
146
- return fiber.tag === HostComponent ||
143
+ return (
144
+ fiber.tag === HostComponent ||
145
fiber.tag === HostRoot ||
148
- fiber.tag === HostPortal;
146
+ fiber.tag === HostPortal
147
+ );
148
}
149
150
function getHostSibling(fiber: Fiber): ?I {
@@ -468,7 +467,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
467
}
468
}
469
if (
471
- finishedWork.effectTag & Callback && finishedWork.updateQueue !== null
470
+ finishedWork.effectTag & Callback &&
471
+ finishedWork.updateQueue !== null
472
) {
473
commitCallbacks(finishedWork, finishedWork.updateQueue, instance);
474
}
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+2
-8
@@ -19,9 +19,7 @@ import type {FiberRoot} from 'ReactFiberRoot';
19
import type {HostConfig} from 'ReactFiberReconciler';
20
21
var {reconcileChildFibers} = require('ReactChildFiber');
22
-var {
23
- popContextProvider,
24
-} = require('ReactFiberContext');
22
+var {popContextProvider} = require('ReactFiberContext');
23
var ReactTypeOfWork = require('ReactTypeOfWork');
24
var ReactTypeOfSideEffect = require('ReactTypeOfSideEffect');
25
var {
@@ -37,10 +35,7 @@ var {
35
YieldComponent,
36
Fragment,
37
} = ReactTypeOfWork;
40
-var {
41
- Ref,
42
- Update,
43
-} = ReactTypeOfSideEffect;
38
+var {Ref, Update} = ReactTypeOfSideEffect;
39
40
if (__DEV__) {
41
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
@@ -342,7 +337,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
337
markUpdate(workInProgress);
338
popHostContainer(workInProgress);
339
return null;
345
-
340
// Error cases
341
case IndeterminateComponent:
342
invariant(
src/renderers/shared/fiber/ReactFiberContext.js
+6
-18
@@ -20,26 +20,14 @@ var emptyObject = require('fbjs/lib/emptyObject');
20
var getComponentName = require('getComponentName');
21
var invariant = require('fbjs/lib/invariant');
22
var warning = require('fbjs/lib/warning');
23
-var {
24
- isFiberMounted,
25
-} = require('ReactFiberTreeReflection');
26
-var {
27
- ClassComponent,
28
- HostRoot,
29
-} = require('ReactTypeOfWork');
30
-const {
31
- createCursor,
32
- pop,
33
- push,
34
-} = require('ReactFiberStack');
23
+var {isFiberMounted} = require('ReactFiberTreeReflection');
24
+var {ClassComponent, HostRoot} = require('ReactTypeOfWork');
25
+const {createCursor, pop, push} = require('ReactFiberStack');
26
27
if (__DEV__) {
28
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
29
var {ReactDebugCurrentFrame} = require('ReactGlobalSharedState');
39
- var {
40
- startPhaseTimer,
41
- stopPhaseTimer,
42
- } = require('ReactDebugFiberPerf');
30
+ var {startPhaseTimer, stopPhaseTimer} = require('ReactDebugFiberPerf');
31
var warnedAboutMissingGetChildContext = {};
32
}
33
@@ -241,8 +229,8 @@ exports.pushContextProvider = function(workInProgress: Fiber): boolean {
229
// We push the context as early as possible to ensure stack integrity.
230
// If the instance does not exist yet, we will push null at first,
231
// and replace it on the stack later when invalidating the context.
244
- const memoizedMergedChildContext = (instance &&
245
- instance.__reactInternalMemoizedMergedChildContext) ||
232
+ const memoizedMergedChildContext =
233
+ (instance && instance.__reactInternalMemoizedMergedChildContext) ||
234
emptyObject;
235
236
// Remember the parent context so we can merge with it later.
src/renderers/shared/fiber/ReactFiberErrorLogger.js
+7
-8
@@ -39,11 +39,7 @@ function logCapturedError(capturedError: CapturedError): void {
39
willRetry,
40
} = capturedError;
41
42
- const {
43
- message,
44
- name,
45
- stack,
46
- } = error;
42
+ const {message, name, stack} = error;
43
44
const errorSummary = message ? `${name}: ${message}` : name;
45
@@ -69,15 +65,18 @@ function logCapturedError(capturedError: CapturedError): void {
65
// errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
66
if (errorBoundaryFound && errorBoundaryName) {
67
if (willRetry) {
72
- errorBoundaryMessage = `React will try to recreate this component tree from scratch ` +
68
+ errorBoundaryMessage =
69
+ `React will try to recreate this component tree from scratch ` +
70
`using the error boundary you provided, ${errorBoundaryName}.`;
71
} else {
75
- errorBoundaryMessage = `This error was initially handled by the error boundary ${errorBoundaryName}. ` +
72
+ errorBoundaryMessage =
73
+ `This error was initially handled by the error boundary ${errorBoundaryName}. ` +
74
`Recreating the tree from scratch failed so React will unmount the tree.`;
75
}
76
} else {
77
// TODO Link to unstable_handleError() documentation once it exists.
80
- errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.';
78
+ errorBoundaryMessage =
79
+ 'Consider adding an error boundary to your tree to customize error handling behavior.';
80
}
81
82
console.error(
src/renderers/shared/fiber/ReactFiberHostContext.js
+2
-9
@@ -16,11 +16,7 @@ import type {Fiber} from 'ReactFiber';
16
import type {HostConfig} from 'ReactFiberReconciler';
17
import type {StackCursor} from 'ReactFiberStack';
18
19
-const {
20
- createCursor,
21
- pop,
22
- push,
23
-} = require('ReactFiberStack');
19
+const {createCursor, pop, push} = require('ReactFiberStack');
20
21
const invariant = require('fbjs/lib/invariant');
22
@@ -40,10 +36,7 @@ export type HostContext<C, CX> = {
36
module.exports = function<T, P, I, TI, PI, C, CX, PL>(
37
config: HostConfig<T, P, I, TI, PI, C, CX, PL>,
38
): HostContext<C, CX> {
43
- const {
44
- getChildHostContext,
45
- getRootHostContext,
46
- } = config;
39
+ const {getChildHostContext, getRootHostContext} = config;
40
41
let contextStackCursor: StackCursor<CX | NoContextT> = createCursor(
42
NO_CONTEXT,
src/renderers/shared/fiber/ReactFiberReconciler.js
+7
-11
@@ -17,9 +17,7 @@ import type {FiberRoot} from 'ReactFiberRoot';
17
import type {PriorityLevel} from 'ReactPriorityLevel';
18
import type {ReactNodeList} from 'ReactTypes';
19
20
-var {
21
- addTopLevelUpdate,
22
-} = require('ReactFiberUpdateQueue');
20
+var {addTopLevelUpdate} = require('ReactFiberUpdateQueue');
21
22
var {
23
findCurrentUnmaskedContext,
@@ -107,9 +105,9 @@ export type HostConfig<T, P, I, TI, PI, C, CX, PL> = {
105
removeChild(parentInstance: I | C, child: I | TI): void,
106
107
scheduleAnimationCallback(callback: () => void): number | void,
110
- scheduleDeferredCallback(callback: (deadline: Deadline) => void):
111
- | number
112
- | void,
108
+ scheduleDeferredCallback(
109
+ callback: (deadline: Deadline) => void,
110
+ ): number | void,
111
112
prepareForCommit(): void,
113
resetAfterCommit(): void,
@@ -131,11 +129,9 @@ export type Reconciler<C, I, TI> = {
129
deferredUpdates<A>(fn: () => A): A,
130
131
// Used to extract the return value from the initial render. Legacy API.
134
- getPublicRootInstance(container: OpaqueRoot):
135
- | ReactComponent<any, any, any>
136
- | TI
137
- | I
138
- | null,
132
+ getPublicRootInstance(
133
+ container: OpaqueRoot,
134
+ ): ReactComponent<any, any, any> | TI | I | null,
135
136
// Use for findDOMNode/findHostNode. Legacy API.
137
findHostInstance(component: Fiber): I | TI | null,
src/renderers/shared/fiber/ReactFiberScheduler.js
+11
-13
@@ -31,9 +31,7 @@ export type HandleErrorInfo = {
31
componentStack: string,
32
};
33
34
-var {
35
- popContextProvider,
36
-} = require('ReactFiberContext');
34
+var {popContextProvider} = require('ReactFiberContext');
35
const {reset} = require('ReactFiberStack');
36
var {
37
getStackAddendumByWorkInProgressFiber,
@@ -81,13 +79,9 @@ var {
79
ClassComponent,
80
} = require('ReactTypeOfWork');
81
84
-var {
85
- getPendingPriority,
86
-} = require('ReactFiberUpdateQueue');
82
+var {getPendingPriority} = require('ReactFiberUpdateQueue');
83
88
-var {
89
- resetContext,
90
-} = require('ReactFiberContext');
84
+var {resetContext} = require('ReactFiberContext');
85
86
var invariant = require('fbjs/lib/invariant');
87
@@ -1148,17 +1142,21 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1142
function hasCapturedError(fiber: Fiber): boolean {
1143
// TODO: capturedErrors should store the boundary instance, to avoid needing
1144
// to check the alternate.
1151
- return capturedErrors !== null &&
1145
+ return (
1146
+ capturedErrors !== null &&
1147
(capturedErrors.has(fiber) ||
1153
- (fiber.alternate !== null && capturedErrors.has(fiber.alternate)));
1148
+ (fiber.alternate !== null && capturedErrors.has(fiber.alternate)))
1149
+ );
1150
}
1151
1152
function isFailedBoundary(fiber: Fiber): boolean {
1153
// TODO: failedBoundaries should store the boundary instance, to avoid
1154
// needing to check the alternate.
1159
- return failedBoundaries !== null &&
1155
+ return (
1156
+ failedBoundaries !== null &&
1157
(failedBoundaries.has(fiber) ||
1161
- (fiber.alternate !== null && failedBoundaries.has(fiber.alternate)));
1158
+ (fiber.alternate !== null && failedBoundaries.has(fiber.alternate)))
1159
+ );
1160
}
1161
1162
function commitErrorHandling(effectfulFiber: Fiber) {
src/renderers/shared/fiber/ReactFiberTreeReflection.js
+1
-4
@@ -31,10 +31,7 @@ var {
31
ClassComponent,
32
} = require('ReactTypeOfWork');
33
34
-var {
35
- NoEffect,
36
- Placement,
37
-} = require('ReactTypeOfSideEffect');
34
+var {NoEffect, Placement} = require('ReactTypeOfSideEffect');
35
36
var MOUNTING = 1;
37
var MOUNTED = 2;
src/renderers/shared/fiber/ReactFiberUpdateQueue.js
+3
-4
@@ -15,9 +15,7 @@
15
import type {Fiber} from 'ReactFiber';
16
import type {PriorityLevel} from 'ReactPriorityLevel';
17
18
-const {
19
- Callback: CallbackEffect,
20
-} = require('ReactTypeOfSideEffect');
18
+const {Callback: CallbackEffect} = require('ReactTypeOfSideEffect');
19
20
const {
21
NoWork,
@@ -431,7 +429,8 @@ function beginUpdateQueue(
429
let callbackList = null;
430
let update = queue.first;
431
while (
434
- update !== null && comparePriority(update.priorityLevel, priorityLevel) <= 0
432
+ update !== null &&
433
+ comparePriority(update.priorityLevel, priorityLevel) <= 0
434
) {
435
// Remove each update from the queue right before it is processed. That way
436
// if setState is called from inside an updater function, the new update
src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
+1
-1
@@ -27,7 +27,7 @@ describe('ReactCoroutine', () => {
27
});
28
29
function div(...children) {
30
- children = children.map(c => typeof c === 'string' ? {text: c} : c);
30
+ children = children.map(c => (typeof c === 'string' ? {text: c} : c));
31
return {type: 'div', children, prop: undefined};
32
}
33
src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
+7
-4
@@ -54,7 +54,7 @@ describe('ReactIncremental', () => {
54
return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
55
}
56
57
- ReactNoop.render(<Foo />, () => renderCallbackCalled = true);
57
+ ReactNoop.render(<Foo />, () => (renderCallbackCalled = true));
58
expect(fooCalled).toBe(false);
59
expect(barCalled).toBe(false);
60
expect(renderCallbackCalled).toBe(false);
@@ -103,7 +103,8 @@ describe('ReactIncremental', () => {
103
}
104
105
ReactNoop.render(<Foo text="foo" />, () =>
106
- ops.push('renderCallbackCalled'));
106
+ ops.push('renderCallbackCalled'),
107
+ );
108
ReactNoop.flush();
109
110
expect(ops).toEqual([
@@ -117,9 +118,11 @@ describe('ReactIncremental', () => {
118
ops = [];
119
120
ReactNoop.render(<Foo text="bar" />, () =>
120
- ops.push('firstRenderCallbackCalled'));
121
+ ops.push('firstRenderCallbackCalled'),
122
+ );
123
ReactNoop.render(<Foo text="bar" />, () =>
122
- ops.push('secondRenderCallbackCalled'));
124
+ ops.push('secondRenderCallbackCalled'),
125
+ );
126
ReactNoop.flush();
127
128
// TODO: Test bail out of host components. This is currently unobservable.
src/renderers/shared/fiber/__tests__/ReactIncrementalErrorHandling-test.js
+1
-1
@@ -27,7 +27,7 @@ describe('ReactIncrementalErrorHandling', () => {
27
});
28
29
function div(...children) {
30
- children = children.map(c => typeof c === 'string' ? {text: c} : c);
30
+ children = children.map(c => (typeof c === 'string' ? {text: c} : c));
31
return {type: 'div', children, prop: undefined};
32
}
33
src/renderers/shared/fiber/__tests__/ReactIncrementalPerf-test.js
+9
-7
@@ -71,12 +71,14 @@ describe('ReactDebugFiberPerf', () => {
71
label: null,
72
parent: activeMeasure,
73
toString() {
74
- return [
75
- ' '.repeat(this.indent) + this.label,
76
- ...this.children.map(c => c.toString()),
77
- ].join('\n') +
74
+ return (
75
+ [
76
+ ' '.repeat(this.indent) + this.label,
77
+ ...this.children.map(c => c.toString()),
78
+ ].join('\n') +
79
// Extra newline after each root reconciliation
79
- (this.indent === 0 ? '\n' : '');
80
+ (this.indent === 0 ? '\n' : '')
81
+ );
82
},
83
};
84
// Step one level deeper
@@ -170,11 +172,11 @@ describe('ReactDebugFiberPerf', () => {
172
<Parent>
173
<Parent>
174
<Parent>
173
- <A ref={inst => a = inst} />
175
+ <A ref={inst => (a = inst)} />
176
</Parent>
177
</Parent>
178
<Parent>
177
- <B ref={inst => b = inst} />
179
+ <B ref={inst => (b = inst)} />
180
</Parent>
181
</Parent>,
182
);
src/renderers/shared/fiber/__tests__/ReactIncrementalReflection-test.js
+3
-3
@@ -151,13 +151,13 @@ describe('ReactIncrementalReflection', () => {
151
render() {
152
ops.push('render');
153
return this.props.step < 2
154
- ? <span ref={ref => this.span = ref} />
154
+ ? <span ref={ref => (this.span = ref)} />
155
: this.props.step === 2
156
- ? <div ref={ref => this.div = ref} />
156
+ ? <div ref={ref => (this.div = ref)} />
157
: this.props.step === 3
158
? null
159
: this.props.step === 4
160
- ? <div ref={ref => this.span = ref} />
160
+ ? <div ref={ref => (this.span = ref)} />
161
: null;
162
}
163
}
src/renderers/shared/fiber/__tests__/ReactIncrementalSideEffects-test.js
+1
-1
@@ -29,7 +29,7 @@ describe('ReactIncrementalSideEffects', () => {
29
}
30
31
function div(...children) {
32
- children = children.map(c => typeof c === 'string' ? {text: c} : c);
32
+ children = children.map(c => (typeof c === 'string' ? {text: c} : c));
33
return {type: 'div', children, prop: undefined};
34
}
35
src/renderers/shared/fiber/isomorphic/ReactCoroutine.js
+8
-4
@@ -88,18 +88,22 @@ exports.createYield = function(value: mixed): ReactYield {
88
* Verifies the object is a coroutine object.
89
*/
90
exports.isCoroutine = function(object: mixed): boolean {
91
- return typeof object === 'object' &&
91
+ return (
92
+ typeof object === 'object' &&
93
object !== null &&
93
- object.$$typeof === REACT_COROUTINE_TYPE;
94
+ object.$$typeof === REACT_COROUTINE_TYPE
95
+ );
96
};
97
98
/**
99
* Verifies the object is a yield object.
100
*/
101
exports.isYield = function(object: mixed): boolean {
100
- return typeof object === 'object' &&
102
+ return (
103
+ typeof object === 'object' &&
104
object !== null &&
102
- object.$$typeof === REACT_YIELD_TYPE;
105
+ object.$$typeof === REACT_YIELD_TYPE
106
+ );
107
};
108
109
exports.REACT_YIELD_TYPE = REACT_YIELD_TYPE;
src/renderers/shared/fiber/isomorphic/ReactPortal.js
+6
-5
@@ -16,9 +16,8 @@ import type {ReactNodeList} from 'ReactTypes';
16
17
// The Symbol used to tag the special React types. If there is no native Symbol
18
// nor polyfill, then a plain number is used for performance.
19
-var REACT_PORTAL_TYPE = (typeof Symbol === 'function' &&
20
- Symbol.for &&
21
- Symbol.for('react.portal')) ||
19
+var REACT_PORTAL_TYPE =
20
+ (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.portal')) ||
21
0xeaca;
22
23
export type ReactPortal = {
@@ -51,9 +50,11 @@ exports.createPortal = function(
50
* Verifies the object is a portal object.
51
*/
52
exports.isPortal = function(object: mixed): boolean {
54
- return typeof object === 'object' &&
53
+ return (
54
+ typeof object === 'object' &&
55
object !== null &&
56
- object.$$typeof === REACT_PORTAL_TYPE;
56
+ object.$$typeof === REACT_PORTAL_TYPE
57
+ );
58
};
59
60
exports.REACT_PORTAL_TYPE = REACT_PORTAL_TYPE;
src/renderers/shared/hooks/ReactHostOperationHistoryHook.js
+10
-12
@@ -14,18 +14,16 @@
14
15
import type {DebugID} from 'ReactInstanceType';
16
17
-export type Operation =
18
- & {instanceID: DebugID}
19
- & (
20
- | {type: 'mount', payload: string}
21
- | {type: 'insert child', payload: {toIndex: number, content: string}}
22
- | {type: 'move child', payload: {fromIndex: number, toIndex: number}}
23
- | {type: 'replace children', payload: string}
24
- | {type: 'replace text', payload: string}
25
- | {type: 'replace with', payload: string}
26
- | {type: 'update styles', payload: mixed /* Style Object */}
27
- | {type: 'update attribute', payload: {[name: string]: string}}
28
- | {type: 'remove attribute', payload: string});
17
+export type Operation = {instanceID: DebugID} & (
18
+ | {type: 'mount', payload: string}
19
+ | {type: 'insert child', payload: {toIndex: number, content: string}}
20
+ | {type: 'move child', payload: {fromIndex: number, toIndex: number}}
21
+ | {type: 'replace children', payload: string}
22
+ | {type: 'replace text', payload: string}
23
+ | {type: 'replace with', payload: string}
24
+ | {type: 'update styles', payload: mixed /* Style Object */}
25
+ | {type: 'update attribute', payload: {[name: string]: string}}
26
+ | {type: 'remove attribute', payload: string});
27
28
// Trust the developer to only use this with a __DEV__ check
29
var ReactHostOperationHistoryHook = ((null: any): typeof ReactHostOperationHistoryHook);
src/renderers/shared/shared/event/EventPluginHub.js
+6
-3
@@ -49,10 +49,12 @@ var executeDispatchesAndReleaseTopLevel = function(e) {
49
};
50
51
function isInteractive(tag) {
52
- return tag === 'button' ||
52
+ return (
53
+ tag === 'button' ||
54
tag === 'input' ||
55
tag === 'select' ||
55
- tag === 'textarea';
56
+ tag === 'textarea'
57
+ );
58
}
59
60
function shouldPreventMouseEvent(name, type, props) {
@@ -140,7 +142,8 @@ var EventPluginHub = {
142
} else {
143
const currentElement = inst._currentElement;
144
if (
143
- typeof currentElement === 'string' || typeof currentElement === 'number'
145
+ typeof currentElement === 'string' ||
146
+ typeof currentElement === 'number'
147
) {
148
// Text node, let it bubble through.
149
return null;
src/renderers/shared/shared/event/EventPluginRegistry.js
+2
-3
@@ -141,9 +141,8 @@ function publishRegistrationName(
141
registrationName,
142
);
143
EventPluginRegistry.registrationNameModules[registrationName] = pluginModule;
144
- EventPluginRegistry.registrationNameDependencies[
145
- registrationName
146
- ] = pluginModule.eventTypes[eventName].dependencies;
144
+ EventPluginRegistry.registrationNameDependencies[registrationName] =
145
+ pluginModule.eventTypes[eventName].dependencies;
146
147
if (__DEV__) {
148
var lowerCasedName = registrationName.toLowerCase();
src/renderers/shared/shared/event/EventPluginUtils.js
+4
-2
@@ -41,9 +41,11 @@ var injection = {
41
};
42
43
function isEndish(topLevelType) {
44
- return topLevelType === 'topMouseUp' ||
44
+ return (
45
+ topLevelType === 'topMouseUp' ||
46
topLevelType === 'topTouchEnd' ||
46
- topLevelType === 'topTouchCancel';
47
+ topLevelType === 'topTouchCancel'
48
+ );
49
}
50
51
function isMoveish(topLevelType) {
src/renderers/shared/shared/event/EventPropagators.js
+2
-3
@@ -27,9 +27,8 @@ var getListener = EventPluginHub.getListener;
27
* "phases" of propagation. This finds listeners by a given phase.
28
*/
29
function listenerAtPhase(inst, event, propagationPhase: PropagationPhases) {
30
- var registrationName = event.dispatchConfig.phasedRegistrationNames[
31
- propagationPhase
32
- ];
30
+ var registrationName =
31
+ event.dispatchConfig.phasedRegistrationNames[propagationPhase];
32
return getListener(inst, registrationName);
33
}
34
src/renderers/shared/shared/event/ReactSyntheticEventType.js
+8
-10
@@ -25,14 +25,12 @@ export type DispatchConfig = {
25
registrationName?: string,
26
};
27
28
-export type ReactSyntheticEvent =
29
- & {
28
+export type ReactSyntheticEvent = {
29
+ dispatchConfig: DispatchConfig,
30
+ getPooled: (
31
dispatchConfig: DispatchConfig,
31
- getPooled: (
32
- dispatchConfig: DispatchConfig,
33
- targetInst: ReactInstance,
34
- nativeTarget: Event,
35
- nativeEventTarget: EventTarget,
36
- ) => ReactSyntheticEvent,
37
- }
38
- & SyntheticEvent;
32
+ targetInst: ReactInstance,
33
+ nativeTarget: Event,
34
+ nativeEventTarget: EventTarget,
35
+ ) => ReactSyntheticEvent,
36
+} & SyntheticEvent;
src/renderers/shared/shared/event/eventPlugins/ResponderEventPlugin.js
+16
-9
@@ -24,7 +24,8 @@ var isMoveish = EventPluginUtils.isMoveish;
24
var isEndish = EventPluginUtils.isEndish;
25
var executeDirectDispatch = EventPluginUtils.executeDirectDispatch;
26
var hasDispatches = EventPluginUtils.hasDispatches;
27
-var executeDispatchesInOrderStopAtTrue = EventPluginUtils.executeDispatchesInOrderStopAtTrue;
27
+var executeDispatchesInOrderStopAtTrue =
28
+ EventPluginUtils.executeDispatchesInOrderStopAtTrue;
29
30
/**
31
* Instance of element that should respond to touch/move types of interactions,
@@ -375,9 +376,11 @@ function setResponderAndExtractTransfer(
376
nativeEvent,
377
nativeEventTarget,
378
);
378
- terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
379
+ terminationRequestEvent.touchHistory =
380
+ ResponderTouchHistoryStore.touchHistory;
381
EventPropagators.accumulateDirectDispatches(terminationRequestEvent);
380
- var shouldSwitch = !hasDispatches(terminationRequestEvent) ||
382
+ var shouldSwitch =
383
+ !hasDispatches(terminationRequestEvent) ||
384
executeDirectDispatch(terminationRequestEvent);
385
if (!terminationRequestEvent.isPersistent()) {
386
terminationRequestEvent.constructor.release(terminationRequestEvent);
@@ -421,14 +424,16 @@ function setResponderAndExtractTransfer(
424
* @return {boolean} True if a transfer of responder could possibly occur.
425
*/
426
function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
424
- return topLevelInst &&
427
+ return (
428
+ topLevelInst &&
429
// responderIgnoreScroll: We are trying to migrate away from specifically
430
// tracking native scroll events here and responderIgnoreScroll indicates we
431
// will send topTouchCancel to handle canceling touch events instead
432
((topLevelType === 'topScroll' && !nativeEvent.responderIgnoreScroll) ||
433
(trackedTouchCount > 0 && topLevelType === 'topSelectionChange') ||
434
isStartish(topLevelType) ||
431
- isMoveish(topLevelType));
435
+ isMoveish(topLevelType))
436
+ );
437
}
438
439
/**
@@ -530,9 +535,10 @@ var ResponderEventPlugin = {
535
extracted = accumulate(extracted, gesture);
536
}
537
533
- var isResponderTerminate = responderInst &&
534
- topLevelType === 'topTouchCancel';
535
- var isResponderRelease = responderInst &&
538
+ var isResponderTerminate =
539
+ responderInst && topLevelType === 'topTouchCancel';
540
+ var isResponderRelease =
541
+ responderInst &&
542
!isResponderTerminate &&
543
isEndish(topLevelType) &&
544
noResponderTouches(nativeEvent);
@@ -552,7 +558,8 @@ var ResponderEventPlugin = {
558
changeResponder(null);
559
}
560
555
- var numberActiveTouches = ResponderTouchHistoryStore.touchHistory.numberActiveTouches;
561
+ var numberActiveTouches =
562
+ ResponderTouchHistoryStore.touchHistory.numberActiveTouches;
563
if (
564
ResponderEventPlugin.GlobalInteractionHandler &&
565
numberActiveTouches !== previousActiveTouches
src/renderers/shared/shared/event/eventPlugins/ResponderTouchHistoryStore.js
+3
-8
@@ -17,11 +17,7 @@ const EventPluginUtils = require('EventPluginUtils');
17
const invariant = require('fbjs/lib/invariant');
18
const warning = require('fbjs/lib/warning');
19
20
-const {
21
- isEndish,
22
- isMoveish,
23
- isStartish,
24
-} = EventPluginUtils;
20
+const {isEndish, isMoveish, isStartish} = EventPluginUtils;
21
22
/**
23
* Tracks the position and time of each active touch by `touch.identifier`. We
@@ -193,9 +189,8 @@ const ResponderTouchHistoryStore = {
189
nativeEvent.changedTouches.forEach(recordTouchStart);
190
touchHistory.numberActiveTouches = nativeEvent.touches.length;
191
if (touchHistory.numberActiveTouches === 1) {
196
- touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[
197
- 0
198
- ].identifier;
192
+ touchHistory.indexOfSingleActiveTouch =
193
+ nativeEvent.touches[0].identifier;
194
}
195
} else if (isEndish(topLevelType)) {
196
nativeEvent.changedTouches.forEach(recordTouchEnd);
src/renderers/shared/shared/event/eventPlugins/__tests__/ResponderEventPlugin-test.js
+4
-6
@@ -256,15 +256,13 @@ var registerTestHandlers = function(eventTestConfig, readableIDToID) {
256
var hasTwoPhase = !!oneEventTypeTestConfig.bubbled;
257
if (hasTwoPhase) {
258
registerOneEventType(
259
- ResponderEventPlugin.eventTypes[
260
- eventName
261
- ].phasedRegistrationNames.bubbled,
259
+ ResponderEventPlugin.eventTypes[eventName].phasedRegistrationNames
260
+ .bubbled,
261
oneEventTypeTestConfig.bubbled,
262
);
263
registerOneEventType(
265
- ResponderEventPlugin.eventTypes[
266
- eventName
267
- ].phasedRegistrationNames.captured,
264
+ ResponderEventPlugin.eventTypes[eventName].phasedRegistrationNames
265
+ .captured,
266
oneEventTypeTestConfig.captured,
267
);
268
} else {
src/renderers/shared/shared/shouldUpdateReactComponent.js
+4
-2
@@ -34,9 +34,11 @@ function shouldUpdateReactComponent(prevElement, nextElement) {
34
if (prevType === 'string' || prevType === 'number') {
35
return nextType === 'string' || nextType === 'number';
36
} else {
37
- return nextType === 'object' &&
37
+ return (
38
+ nextType === 'object' &&
39
prevElement.type === nextElement.type &&
39
- prevElement.key === nextElement.key;
40
+ prevElement.key === nextElement.key
41
+ );
42
}
43
}
44
src/renderers/shared/stack/reconciler/ReactChildReconciler.js
+8
-4
@@ -32,7 +32,8 @@ if (
32
// https://github.com/facebook/react/issues/7240
33
// Remove the inline requires when we don't need them anymore:
34
// https://github.com/facebook/react/pull/7178
35
- ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
35
+ ReactComponentTreeHook = require('ReactGlobalSharedState')
36
+ .ReactComponentTreeHook;
37
}
38
39
function instantiateChild(childInstances, child, name, selfDebugID) {
@@ -40,7 +41,8 @@ function instantiateChild(childInstances, child, name, selfDebugID) {
41
var keyUnique = childInstances[name] === undefined;
42
if (__DEV__) {
43
if (!ReactComponentTreeHook) {
43
- ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
44
+ ReactComponentTreeHook = require('ReactGlobalSharedState')
45
+ .ReactComponentTreeHook;
46
}
47
if (!keyUnique) {
48
warning(
@@ -147,7 +149,8 @@ var ReactChildReconciler = {
149
nextChildren[name] = prevChild;
150
} else {
151
if (
150
- !ReactFeatureFlags.prepareNewChildrenBeforeUnmountInStack && prevChild
152
+ !ReactFeatureFlags.prepareNewChildrenBeforeUnmountInStack &&
153
+ prevChild
154
) {
155
removedNodes[name] = ReactReconciler.getHostNode(prevChild);
156
ReactReconciler.unmountComponent(
@@ -171,7 +174,8 @@ var ReactChildReconciler = {
174
);
175
mountImages.push(nextChildMountImage);
176
if (
174
- ReactFeatureFlags.prepareNewChildrenBeforeUnmountInStack && prevChild
177
+ ReactFeatureFlags.prepareNewChildrenBeforeUnmountInStack &&
178
+ prevChild
179
) {
180
removedNodes[name] = ReactReconciler.getHostNode(prevChild);
181
ReactReconciler.unmountComponent(
src/renderers/shared/stack/reconciler/ReactComponentEnvironment.js
+4
-2
@@ -43,8 +43,10 @@ var ReactComponentEnvironment = {
43
!injected,
44
'ReactCompositeComponent: injectEnvironment() can only be called once.',
45
);
46
- ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
47
- ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
46
+ ReactComponentEnvironment.replaceNodeWithMarkup =
47
+ environment.replaceNodeWithMarkup;
48
+ ReactComponentEnvironment.processChildrenUpdates =
49
+ environment.processChildrenUpdates;
50
injected = true;
51
},
52
},
src/renderers/shared/stack/reconciler/ReactCompositeComponent.js
+9
-7
@@ -222,9 +222,8 @@ var ReactCompositeComponent = {
222
}
223
224
var propsMutated = inst.props !== publicProps;
225
- var componentName = Component.displayName ||
226
- Component.name ||
227
- 'Component';
225
+ var componentName =
226
+ Component.displayName || Component.name || 'Component';
227
228
warning(
229
inst.props === undefined || !propsMutated,
@@ -304,7 +303,7 @@ var ReactCompositeComponent = {
303
304
var initialState = inst.state;
305
if (initialState === undefined) {
307
- inst.state = (initialState = null);
306
+ inst.state = initialState = null;
307
}
308
invariant(
309
typeof initialState === 'object' && !Array.isArray(initialState),
@@ -898,7 +897,8 @@ var ReactCompositeComponent = {
897
}
898
} else {
899
if (this._compositeType === ReactCompositeComponentTypes.PureClass) {
901
- shouldUpdate = !shallowEqual(prevProps, nextProps) ||
900
+ shouldUpdate =
901
+ !shallowEqual(prevProps, nextProps) ||
902
!shallowEqual(inst.state, nextState);
903
}
904
}
@@ -1309,11 +1309,13 @@ var ReactCompositeComponent = {
1309
getName: function() {
1310
var type = this._currentElement.type;
1311
var constructor = this._instance && this._instance.constructor;
1312
- return type.displayName ||
1312
+ return (
1313
+ type.displayName ||
1314
(constructor && constructor.displayName) ||
1315
type.name ||
1316
(constructor && constructor.name) ||
1316
- null;
1317
+ null
1318
+ );
1319
},
1320
1321
/**
src/renderers/shared/stack/reconciler/ReactRef.js
+6
-5
@@ -47,9 +47,8 @@ function attachRef(ref, component, owner) {
47
let warningKey = ownerName || component._debugID;
48
let element = component._currentElement;
49
if (element && element._source) {
50
- warningKey = element._source.fileName +
51
- ':' +
52
- element._source.lineNumber;
50
+ warningKey =
51
+ element._source.fileName + ':' + element._source.lineNumber;
52
}
53
if (!warnedAboutStatelessRefs[warningKey]) {
54
warnedAboutStatelessRefs[warningKey] = true;
@@ -124,9 +123,11 @@ ReactRef.shouldUpdateRefs = function(
123
nextOwner = nextElement._owner;
124
}
125
127
- return prevRef !== nextRef ||
126
+ return (
127
+ prevRef !== nextRef ||
128
// If owner changes but we have an unchanged function ref, don't update refs
129
- (typeof nextRef === 'string' && nextOwner !== prevOwner);
129
+ (typeof nextRef === 'string' && nextOwner !== prevOwner)
130
+ );
131
};
132
133
ReactRef.detachRefs = function(
src/renderers/shared/stack/reconciler/ReactUpdateQueue.js
+2
-1
@@ -226,7 +226,8 @@ var ReactUpdateQueue = {
226
return;
227
}
228
229
- var queue = internalInstance._pendingStateQueue ||
229
+ var queue =
230
+ internalInstance._pendingStateQueue ||
231
(internalInstance._pendingStateQueue = []);
232
queue.push(partialState);
233
src/renderers/shared/stack/reconciler/Transaction.js
+10
-8
@@ -124,14 +124,16 @@ var TransactionImpl = {
124
*
125
* @return {*} Return value from `method`.
126
*/
127
- perform: function<A, B, C, D, E, F, G, T: (
128
- a: A,
129
- b: B,
130
- c: C,
131
- d: D,
132
- e: E,
133
- f: F,
134
- ) => G>(method: T, scope: any, a: A, b: B, c: C, d: D, e: E, f: F): G {
127
+ perform: function<
128
+ A,
129
+ B,
130
+ C,
131
+ D,
132
+ E,
133
+ F,
134
+ G,
135
+ T: (a: A, b: B, c: C, d: D, e: E, f: F) => G
136
+ >(method: T, scope: any, a: A, b: B, c: C, d: D, e: E, f: F): G {
137
invariant(
138
!this.isInTransaction(),
139
'Transaction.perform(...): Cannot initialize a transaction when there ' +
src/renderers/shared/stack/reconciler/flattenStackChildren.js
+4
-2
@@ -28,7 +28,8 @@ if (
28
// https://github.com/facebook/react/issues/7240
29
// Remove the inline requires when we don't need them anymore:
30
// https://github.com/facebook/react/pull/7178
31
- ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
31
+ ReactComponentTreeHook = require('ReactGlobalSharedState')
32
+ .ReactComponentTreeHook;
33
}
34
35
/**
@@ -49,7 +50,8 @@ function flattenSingleChildIntoContext(
50
const keyUnique = result[name] === undefined;
51
if (__DEV__) {
52
if (!ReactComponentTreeHook) {
52
- ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
53
+ ReactComponentTreeHook = require('ReactGlobalSharedState')
54
+ .ReactComponentTreeHook;
55
}
56
if (!keyUnique) {
57
warning(
src/renderers/shared/stack/reconciler/instantiateReactComponent.js
+6
-3
@@ -42,10 +42,12 @@ function getDeclarationErrorAddendum(owner) {
42
* @return {boolean} Returns true if this is a valid internal type.
43
*/
44
function isInternalComponentType(type) {
45
- return typeof type === 'function' &&
45
+ return (
46
+ typeof type === 'function' &&
47
typeof type.prototype !== 'undefined' &&
48
typeof type.prototype.mountComponent === 'function' &&
48
- typeof type.prototype.receiveComponent === 'function';
49
+ typeof type.prototype.receiveComponent === 'function'
50
+ );
51
}
52
53
/**
@@ -73,7 +75,8 @@ function instantiateReactComponent(node, shouldHaveDebugID) {
75
type !== null &&
76
Object.keys(type).length === 0)
77
) {
76
- info += ' You likely forgot to export your component from the file ' +
78
+ info +=
79
+ ' You likely forgot to export your component from the file ' +
80
"it's defined in.";
81
}
82
}
src/renderers/shared/stack/reconciler/traverseStackChildren.js
+2
-1
@@ -146,7 +146,8 @@ function traverseStackChildrenImpl(
146
} else if (type === 'object') {
147
var addendum = '';
148
if (__DEV__) {
149
- addendum = ' If you meant to render a collection of children, use an array ' +
149
+ addendum =
150
+ ' If you meant to render a collection of children, use an array ' +
151
'instead.' +
152
getCurrentStackAddendum();
153
}
src/renderers/shared/utils/adler32.js
+4
-3
@@ -28,7 +28,8 @@ function adler32(data: string): number {
28
while (i < m) {
29
var n = Math.min(i + 4096, m);
30
for (; i < n; i += 4) {
31
- b += (a += data.charCodeAt(i)) +
31
+ b +=
32
+ (a += data.charCodeAt(i)) +
33
(a += data.charCodeAt(i + 1)) +
34
(a += data.charCodeAt(i + 2)) +
35
(a += data.charCodeAt(i + 3));
@@ -37,11 +38,11 @@ function adler32(data: string): number {
38
b %= MOD;
39
}
40
for (; i < l; i++) {
40
- b += (a += data.charCodeAt(i));
41
+ b += a += data.charCodeAt(i);
42
}
43
a %= MOD;
44
b %= MOD;
44
- return a | b << 16;
45
+ return a | (b << 16);
46
}
47
48
module.exports = adler32;
src/renderers/testing/ReactShallowRenderer.js
+4
-2
@@ -224,11 +224,13 @@ class Updater {
224
225
function getName(type, instance) {
226
var constructor = instance && instance.constructor;
227
- return type.displayName ||
227
+ return (
228
+ type.displayName ||
229
(constructor && constructor.displayName) ||
230
type.name ||
231
(constructor && constructor.name) ||
231
- null;
232
+ null
233
+ );
234
}
235
236
function shouldConstruct(Component) {
src/shared/ReactFiberComponentTreeHook.js
+4
-2
@@ -24,7 +24,8 @@ var getComponentName = require('getComponentName');
24
import type {Fiber} from 'ReactFiber';
25
26
function describeComponentFrame(name, source: any, ownerName) {
27
- return '\n in ' +
27
+ return (
28
+ '\n in ' +
29
(name || 'Unknown') +
30
(source
31
? ' (at ' +
@@ -32,7 +33,8 @@ function describeComponentFrame(name, source: any, ownerName) {
33
':' +
34
source.lineNumber +
35
')'
35
- : ownerName ? ' (created by ' + ownerName + ')' : '');
36
+ : ownerName ? ' (created by ' + ownerName + ')' : '')
37
+ );
38
}
39
40
function describeFiber(fiber: Fiber): string {
src/shared/utils/PooledClass.js
+1
-1
@@ -95,7 +95,7 @@ var addPoolingTo = function<T>(
95
CopyConstructor: Class<T>,
96
pooler: Pooler,
97
): Class<T> & {
98
- getPooled /* arguments of the constructor */(): T,
98
+ getPooled(): /* arguments of the constructor */ T,
99
release(): void,
100
} {
101
// Casting as any so that flow ignores the actual implementation and trusts
src/shared/utils/ReactElementSymbol.js
+2
-3
@@ -14,9 +14,8 @@
14
15
// The Symbol used to tag the ReactElement type. If there is no native Symbol
16
// nor polyfill, then a plain number is used for performance.
17
-var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
18
- Symbol.for &&
19
- Symbol.for('react.element')) ||
17
+var REACT_ELEMENT_TYPE =
18
+ (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) ||
19
0xeac7;
20
21
module.exports = REACT_ELEMENT_TYPE;
src/shared/utils/getIteratorFn.js
+2
-1
@@ -31,7 +31,8 @@ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
31
* @return {?function}
32
*/
33
function getIteratorFn(maybeIterable: ?any): ?() => ?Iterator<*> {
34
- var iteratorFn = maybeIterable &&
34
+ var iteratorFn =
35
+ maybeIterable &&
36
((ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL]) ||
37
maybeIterable[FAUX_ITERATOR_SYMBOL]);
38
if (typeof iteratorFn === 'function') {
src/shared/utils/reactProdInvariant.js
+4
-2
@@ -20,7 +20,8 @@
20
function reactProdInvariant(code: string): void {
21
var argCount = arguments.length - 1;
22
23
- var message = 'Minified React error #' +
23
+ var message =
24
+ 'Minified React error #' +
25
code +
26
'; visit ' +
27
'http://facebook.github.io/react/docs/error-decoder.html?invariant=' +
@@ -30,7 +31,8 @@ function reactProdInvariant(code: string): void {
31
message += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
32
}
33
33
- message += ' for the full message or use the non-minified dev environment' +
34
+ message +=
35
+ ' for the full message or use the non-minified dev environment' +
36
' for full errors and additional helpful warnings.';
37
38
var error: Error & {framesToPop?: number} = new Error(message);
yarn.lock
+19
-23
@@ -225,18 +225,14 @@ ast-types@0.8.12:
225
version "0.8.12"
226
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.12.tgz#a0d90e4351bb887716c83fd637ebf818af4adfcc"
227
228
-ast-types@0.8.18:
229
- version "0.8.18"
230
- resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.18.tgz#c8b98574898e8914e9d8de74b947564a9fe929af"
231
-
232
-ast-types@0.9.4:
233
- version "0.9.4"
234
- resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.4.tgz#410d1f81890aeb8e0a38621558ba5869ae53c91b"
235
-
228
ast-types@0.9.6:
229
version "0.9.6"
230
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.6.tgz#102c9e9e9005d3e7e3829bf0c4fa24ee862ee9b9"
231
232
+ast-types@0.9.8:
233
+ version "0.9.8"
234
+ resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.8.tgz#6cb6a40beba31f49f20928e28439fc14a3dab078"
235
+
236
astw@^2.0.0:
237
version "2.2.0"
238
resolved "https://registry.yarnpkg.com/astw/-/astw-2.2.0.tgz#7bd41784d32493987aeb239b6b4e1c57a873b917"
@@ -896,6 +892,10 @@ babylon@6.15.0, babylon@^6.11.0:
892
version "6.15.0"
893
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e"
894
895
+babylon@7.0.0-beta.8:
896
+ version "7.0.0-beta.8"
897
+ resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.8.tgz#2bdc5ae366041442c27e068cce6f0d7c06ea9949"
898
+
899
babylon@^5.8.38:
900
version "5.8.38"
901
resolved "https://registry.yarnpkg.com/babylon/-/babylon-5.8.38.tgz#ec9b120b11bf6ccd4173a18bf217e60b79859ffd"
@@ -1303,7 +1303,7 @@ color-name@^1.1.1:
1303
version "1.1.2"
1304
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d"
1305
1306
-colors@1.0.3, colors@>=0.6.2:
1306
+colors@1.0.3:
1307
version "1.0.3"
1308
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
1309
@@ -2143,13 +2143,9 @@ flow-bin@^0.41.0:
2143
version "0.41.0"
2144
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.41.0.tgz#8badac9a19da45004997e599bd316518db489b2e"
2145
2146
-flow-parser@0.40.0:
2147
- version "0.40.0"
2148
- resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.40.0.tgz#b3444742189093323c4319c4fe9d35391f46bcbc"
2149
- dependencies:
2150
- ast-types "0.8.18"
2151
- colors ">=0.6.2"
2152
- minimist ">=0.2.0"
2146
+flow-parser@0.43.0:
2147
+ version "0.43.0"
2148
+ resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.43.0.tgz#e2b8eb1ac83dd53f7b6b04a7c35b6a52c33479b7"
2149
2150
for-in@^1.0.1:
2151
version "1.0.2"
@@ -3514,7 +3510,7 @@ minimist@0.0.8, minimist@~0.0.1:
3510
version "0.0.8"
3511
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
3512
3517
-minimist@1.2.0, minimist@>=0.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0:
3513
+minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0:
3514
version "1.2.0"
3515
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
3516
@@ -3887,16 +3883,16 @@ preserve@^0.2.0:
3883
version "0.2.0"
3884
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
3885
3890
-prettier@^0.22.0:
3891
- version "0.22.0"
3892
- resolved "https://registry.yarnpkg.com/prettier/-/prettier-0.22.0.tgz#7b37c4480d0858180407e5a8e13f0f47da7385d2"
3886
+prettier@^1.2.2:
3887
+ version "1.2.2"
3888
+ resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.2.2.tgz#22d17c1132faaaea1f1d4faea31f19f7a1959f3e"
3889
dependencies:
3894
- ast-types "0.9.4"
3890
+ ast-types "0.9.8"
3891
babel-code-frame "6.22.0"
3896
- babylon "6.15.0"
3892
+ babylon "7.0.0-beta.8"
3893
chalk "1.1.3"
3894
esutils "2.0.2"
3899
- flow-parser "0.40.0"
3895
+ flow-parser "0.43.0"
3896
get-stdin "5.0.1"
3897
glob "7.1.1"
3898
jest-validate "19.0.0"