@samitouri / QOS-React / commits / 6074664f73

react-reconciler: convert vars into let/const (#11729)

Raphael Amorim committed Nov 30, 2017 at 21:59 UTC 6074664f73c6b1ea1f774f2bc698224e3677cef0
24 files changed +170 -162
packages/react-reconciler/index.js
+1 -1
@@ -16,7 +16,7 @@ export type {
16 Reconciler,
17 } from './src/ReactFiberReconciler';
18
19 -var ReactFiberReconciler = require('./src/ReactFiberReconciler');
19 +const ReactFiberReconciler = require('./src/ReactFiberReconciler');
20
21 // TODO: decide on the top-level export form.
22 // This is hacky but makes it work with both Rollup and Jest.
packages/react-reconciler/src/ReactDebugCurrentFiber.js
+1 -1
@@ -58,7 +58,7 @@ function setCurrentPhase(phase: LifeCyclePhase | null) {
58 ReactDebugCurrentFiber.phase = phase;
59 }
60
61 -var ReactDebugCurrentFiber = {
61 +const ReactDebugCurrentFiber = {
62 current: (null: Fiber | null),
63 phase: (null: LifeCyclePhase | null),
64 resetCurrentFiber,
packages/react-reconciler/src/ReactFiber.js
+2 -2
@@ -40,7 +40,7 @@ import {NoContext} from './ReactTypeOfInternalContext';
40 if (__DEV__) {
41 var hasBadMapPolyfill = false;
42 try {
43 - const nonExtensibleObject = Object.preventExtensions({});
43 + var nonExtensibleObject = Object.preventExtensions({});
44 /* eslint-disable no-new */
45 new Map([[nonExtensibleObject, null]]);
46 new Set([nonExtensibleObject]);
@@ -212,7 +212,7 @@ function FiberNode(
212 // is faster.
213 // 5) It should be easy to port this to a C struct and keep a C implementation
214 // compatible.
215 -var createFiber = function(
215 +const createFiber = function(
216 tag: TypeOfWork,
217 pendingProps: mixed,
218 key: null | string,
packages/react-reconciler/src/ReactFiberBeginWork.js
+9 -9
@@ -180,10 +180,10 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
180 // It used to be here.
181 }
182
183 - var unmaskedContext = getUnmaskedContext(workInProgress);
184 - var context = getMaskedContext(workInProgress, unmaskedContext);
183 + const unmaskedContext = getUnmaskedContext(workInProgress);
184 + const context = getMaskedContext(workInProgress, unmaskedContext);
185
186 - var nextChildren;
186 + let nextChildren;
187
188 if (__DEV__) {
189 ReactCurrentOwner.current = workInProgress;
@@ -438,12 +438,12 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
438 'An indeterminate component should never have mounted. This error is ' +
439 'likely caused by a bug in React. Please file an issue.',
440 );
441 - var fn = workInProgress.type;
442 - var props = workInProgress.pendingProps;
443 - var unmaskedContext = getUnmaskedContext(workInProgress);
444 - var context = getMaskedContext(workInProgress, unmaskedContext);
441 + const fn = workInProgress.type;
442 + const props = workInProgress.pendingProps;
443 + const unmaskedContext = getUnmaskedContext(workInProgress);
444 + const context = getMaskedContext(workInProgress, unmaskedContext);
445
446 - var value;
446 + let value;
447
448 if (__DEV__) {
449 if (fn.prototype && typeof fn.prototype.render === 'function') {
@@ -523,7 +523,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
523 }
524
525 function updateCallComponent(current, workInProgress, renderExpirationTime) {
526 - var nextCall = (workInProgress.pendingProps: ReactCall);
526 + let nextCall = (workInProgress.pendingProps: ReactCall);
527 if (hasContextChanged()) {
528 // Normally we can bail out on props equality but if context has changed
529 // we don't do the bailout and we have to reuse existing props instead.
packages/react-reconciler/src/ReactFiberCommitWork.js
+6 -2
@@ -31,7 +31,11 @@ import {commitCallbacks} from './ReactFiberUpdateQueue';
31 import {onCommitUnmount} from './ReactFiberDevToolsHook';
32 import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf';
33
34 -var {invokeGuardedCallback, hasCaughtError, clearCaughtError} = ReactErrorUtils;
34 +const {
35 + invokeGuardedCallback,
36 + hasCaughtError,
37 + clearCaughtError,
38 +} = ReactErrorUtils;
39
40 export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
41 config: HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL>,
@@ -39,7 +43,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
43 ) {
44 const {getPublicInstance, mutation, persistence} = config;
45
42 - var callComponentWillUnmountWithTimer = function(current, instance) {
46 + const callComponentWillUnmountWithTimer = function(current, instance) {
47 startPhaseTimer(current, 'componentWillUnmount');
48 instance.props = current.memoizedProps;
49 instance.state = current.memoizedState;
packages/react-reconciler/src/ReactFiberCompleteWork.js
+6 -6
@@ -115,7 +115,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
115 workInProgress: Fiber,
116 renderExpirationTime: ExpirationTime,
117 ) {
118 - var call = (workInProgress.memoizedProps: ?ReactCall);
118 + const call = (workInProgress.memoizedProps: ?ReactCall);
119 invariant(
120 call,
121 'Should be resolved by now. This error is likely caused by a bug in ' +
@@ -133,13 +133,13 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
133
134 // Build up the returns.
135 // TODO: Compare this to a generator or opaque helpers like Children.
136 - var returns: Array<mixed> = [];
136 + const returns: Array<mixed> = [];
137 appendAllReturns(returns, workInProgress);
138 - var fn = call.handler;
139 - var props = call.props;
140 - var nextChildren = fn(props, returns);
138 + const fn = call.handler;
139 + const props = call.props;
140 + const nextChildren = fn(props, returns);
141
142 - var currentFirstChild = current !== null ? current.child : null;
142 + const currentFirstChild = current !== null ? current.child : null;
143 workInProgress.child = reconcileChildFibers(
144 workInProgress,
145 currentFirstChild,
packages/react-reconciler/src/ReactFiberInstrumentation.js
+1 -1
@@ -11,7 +11,7 @@
11 // See https://github.com/facebook/react/pull/8033.
12 // This is not part of the public API, not even for React DevTools.
13 // You may only inject a debugTool if you work on React Fiber itself.
14 -var ReactFiberInstrumentation = {
14 +const ReactFiberInstrumentation = {
15 debugTool: null,
16 };
17
packages/react-reconciler/src/ReactFiberReconciler.js
+2 -2
@@ -285,9 +285,9 @@ function getContextForSubtree(
285 export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
286 config: HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL>,
287 ): Reconciler<C, I, TI> {
288 - var {getPublicInstance} = config;
288 + const {getPublicInstance} = config;
289
290 - var {
290 + const {
291 computeAsyncExpiration,
292 computeUniqueAsyncExpiration,
293 computeExpirationForFiber,
packages/react-reconciler/src/ReactFiberScheduler.js
+6 -2
@@ -79,7 +79,11 @@ import {AsyncUpdates} from './ReactTypeOfInternalContext';
79 import {getUpdateExpirationTime} from './ReactFiberUpdateQueue';
80 import {resetContext} from './ReactFiberContext';
81
82 -var {invokeGuardedCallback, hasCaughtError, clearCaughtError} = ReactErrorUtils;
82 +const {
83 + invokeGuardedCallback,
84 + hasCaughtError,
85 + clearCaughtError,
86 +} = ReactErrorUtils;
87
88 export type CapturedError = {
89 componentName: ?string,
@@ -101,7 +105,7 @@ if (__DEV__) {
105 var didWarnStateUpdateForUnmountedComponent = {};
106
107 var warnAboutUpdateOnUnmounted = function(fiber: Fiber) {
104 - const componentName = getComponentName(fiber) || 'ReactClass';
108 + var componentName = getComponentName(fiber) || 'ReactClass';
109 if (didWarnStateUpdateForUnmountedComponent[componentName]) {
110 return;
111 }
packages/react-reconciler/src/ReactFiberTreeReflection.js
+4 -4
@@ -24,9 +24,9 @@ import {
24 } from 'shared/ReactTypeOfWork';
25 import {NoEffect, Placement} from 'shared/ReactTypeOfSideEffect';
26
27 -var MOUNTING = 1;
28 -var MOUNTED = 2;
29 -var UNMOUNTED = 3;
27 +const MOUNTING = 1;
28 +const MOUNTED = 2;
29 +const UNMOUNTED = 3;
30
31 function isFiberMountedImpl(fiber: Fiber): number {
32 let node = fiber;
@@ -80,7 +80,7 @@ export function isMounted(component: React$Component<any, any>): boolean {
80 }
81 }
82
83 - var fiber: ?Fiber = ReactInstanceMap.get(component);
83 + const fiber: ?Fiber = ReactInstanceMap.get(component);
84 if (!fiber) {
85 return false;
86 }
packages/react-reconciler/src/__tests__/ReactExpiration-test.js
+2 -2
@@ -7,8 +7,8 @@
7
8 'use strict';
9
10 -var React;
11 -var ReactNoop;
10 +let React;
11 +let ReactNoop;
12
13 describe('ReactExpiration', () => {
14 beforeEach(() => {
packages/react-reconciler/src/__tests__/ReactFiberHostContext-test.js
+4 -4
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactFiberReconciler;
12 +let React;
13 +let ReactFiberReconciler;
14
15 describe('ReactFiberHostContext', () => {
16 beforeEach(() => {
@@ -20,8 +20,8 @@ describe('ReactFiberHostContext', () => {
20 });
21
22 it('works with null host context', () => {
23 - var creates = 0;
24 - var Renderer = ReactFiberReconciler({
23 + let creates = 0;
24 + const Renderer = ReactFiberReconciler({
25 prepareForCommit: function() {},
26 resetAfterCommit: function() {},
27 getRootHostContext: function() {
packages/react-reconciler/src/__tests__/ReactFragment-test.js
+16 -16
@@ -81,7 +81,7 @@ describe('ReactFragment', () => {
81 });
82
83 it('should preserve state of children with 1 level nesting', function() {
84 - var ops = [];
84 + const ops = [];
85
86 class Stateful extends React.Component {
87 componentDidUpdate() {
@@ -121,7 +121,7 @@ describe('ReactFragment', () => {
121 });
122
123 it('should preserve state between top-level fragments', function() {
124 - var ops = [];
124 + const ops = [];
125
126 class Stateful extends React.Component {
127 componentDidUpdate() {
@@ -162,7 +162,7 @@ describe('ReactFragment', () => {
162 });
163
164 it('should preserve state of children nested at same level', function() {
165 - var ops = [];
165 + const ops = [];
166
167 class Stateful extends React.Component {
168 componentDidUpdate() {
@@ -212,7 +212,7 @@ describe('ReactFragment', () => {
212 });
213
214 it('should not preserve state in non-top-level fragment nesting', function() {
215 - var ops = [];
215 + const ops = [];
216
217 class Stateful extends React.Component {
218 componentDidUpdate() {
@@ -255,7 +255,7 @@ describe('ReactFragment', () => {
255 });
256
257 it('should not preserve state of children if nested 2 levels without siblings', function() {
258 - var ops = [];
258 + const ops = [];
259
260 class Stateful extends React.Component {
261 componentDidUpdate() {
@@ -296,7 +296,7 @@ describe('ReactFragment', () => {
296 });
297
298 it('should not preserve state of children if nested 2 levels with siblings', function() {
299 - var ops = [];
299 + const ops = [];
300
301 class Stateful extends React.Component {
302 componentDidUpdate() {
@@ -338,7 +338,7 @@ describe('ReactFragment', () => {
338 });
339
340 it('should preserve state between array nested in fragment and fragment', function() {
341 - var ops = [];
341 + const ops = [];
342
343 class Stateful extends React.Component {
344 componentDidUpdate() {
@@ -377,7 +377,7 @@ describe('ReactFragment', () => {
377 });
378
379 it('should preserve state between top level fragment and array', function() {
380 - var ops = [];
380 + const ops = [];
381
382 class Stateful extends React.Component {
383 componentDidUpdate() {
@@ -416,7 +416,7 @@ describe('ReactFragment', () => {
416 });
417
418 it('should not preserve state between array nested in fragment and double nested fragment', function() {
419 - var ops = [];
419 + const ops = [];
420
421 class Stateful extends React.Component {
422 componentDidUpdate() {
@@ -457,7 +457,7 @@ describe('ReactFragment', () => {
457 });
458
459 it('should not preserve state between array nested in fragment and double nested array', function() {
460 - var ops = [];
460 + const ops = [];
461
462 class Stateful extends React.Component {
463 componentDidUpdate() {
@@ -494,7 +494,7 @@ describe('ReactFragment', () => {
494 });
495
496 it('should preserve state between double nested fragment and double nested array', function() {
497 - var ops = [];
497 + const ops = [];
498
499 class Stateful extends React.Component {
500 componentDidUpdate() {
@@ -535,7 +535,7 @@ describe('ReactFragment', () => {
535 });
536
537 it('should not preserve state of children when the keys are different', function() {
538 - var ops = [];
538 + const ops = [];
539
540 class Stateful extends React.Component {
541 componentDidUpdate() {
@@ -577,7 +577,7 @@ describe('ReactFragment', () => {
577 });
578
579 it('should not preserve state between unkeyed and keyed fragment', function() {
580 - var ops = [];
580 + const ops = [];
581
582 class Stateful extends React.Component {
583 componentDidUpdate() {
@@ -618,7 +618,7 @@ describe('ReactFragment', () => {
618 });
619
620 it('should preserve state with reordering in multiple levels', function() {
621 - var ops = [];
621 + const ops = [];
622
623 class Stateful extends React.Component {
624 componentDidUpdate() {
@@ -672,7 +672,7 @@ describe('ReactFragment', () => {
672
673 it('should not preserve state when switching to a keyed fragment to an array', function() {
674 spyOnDev(console, 'error');
675 - var ops = [];
675 + const ops = [];
676
677 class Stateful extends React.Component {
678 componentDidUpdate() {
@@ -726,7 +726,7 @@ describe('ReactFragment', () => {
726
727 it('should preserve state when it does not change positions', function() {
728 spyOnDev(console, 'error');
729 - var ops = [];
729 + const ops = [];
730
731 class Stateful extends React.Component {
732 componentDidUpdate() {
packages/react-reconciler/src/__tests__/ReactIncremental-test.js
+40 -40
@@ -9,9 +9,9 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
14 -var PropTypes;
12 +let React;
13 +let ReactNoop;
14 +let PropTypes;
15
16 describe('ReactIncremental', () => {
17 beforeEach(() => {
@@ -35,8 +35,8 @@ describe('ReactIncremental', () => {
35 });
36
37 it('should render a simple component, in steps if needed', () => {
38 - var renderCallbackCalled = false;
39 - var barCalled = false;
38 + let renderCallbackCalled = false;
39 + let barCalled = false;
40 function Bar() {
41 barCalled = true;
42 return (
@@ -46,7 +46,7 @@ describe('ReactIncremental', () => {
46 );
47 }
48
49 - var fooCalled = false;
49 + let fooCalled = false;
50 function Foo() {
51 fooCalled = true;
52 return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
@@ -69,7 +69,7 @@ describe('ReactIncremental', () => {
69 });
70
71 it('updates a previous render', () => {
72 - var ops = [];
72 + let ops = [];
73
74 function Header() {
75 ops.push('Header');
@@ -86,8 +86,8 @@ describe('ReactIncremental', () => {
86 return <footer>Bye</footer>;
87 }
88
89 - var header = <Header />;
90 - var footer = <Footer />;
89 + const header = <Header />;
90 + const footer = <Footer />;
91
92 function Foo(props) {
93 ops.push('Foo');
@@ -136,7 +136,7 @@ describe('ReactIncremental', () => {
136 });
137
138 it('can cancel partially rendered work and restart', () => {
139 - var ops = [];
139 + let ops = [];
140
141 function Bar(props) {
142 ops.push('Bar');
@@ -245,7 +245,7 @@ describe('ReactIncremental', () => {
245 });
246
247 it('can deprioritize unfinished work and resume it later', () => {
248 - var ops = [];
248 + let ops = [];
249
250 function Bar(props) {
251 ops.push('Bar');
@@ -297,7 +297,7 @@ describe('ReactIncremental', () => {
297 });
298
299 it('can deprioritize a tree from without dropping work', () => {
300 - var ops = [];
300 + let ops = [];
301
302 function Bar(props) {
303 ops.push('Bar');
@@ -349,7 +349,7 @@ describe('ReactIncremental', () => {
349 });
350
351 xit('can resume work in a subtree even when a parent bails out', () => {
352 - var ops = [];
352 + let ops = [];
353
354 function Bar(props) {
355 ops.push('Bar');
@@ -368,7 +368,7 @@ describe('ReactIncremental', () => {
368 return <span>{props.children}</span>;
369 }
370
371 - var middleContent = (
371 + const middleContent = (
372 <aaa>
373 <Tester />
374 <bbb hidden={true}>
@@ -412,7 +412,7 @@ describe('ReactIncremental', () => {
412 });
413
414 xit('can resume work in a bailed subtree within one pass', () => {
415 - var ops = [];
415 + let ops = [];
416
417 function Bar(props) {
418 ops.push('Bar');
@@ -620,7 +620,7 @@ describe('ReactIncremental', () => {
620 });
621
622 xit('can reuse work done after being preempted', () => {
623 - var ops = [];
623 + let ops = [];
624
625 function Bar(props) {
626 ops.push('Bar');
@@ -632,7 +632,7 @@ describe('ReactIncremental', () => {
632 return <span>{props.children}</span>;
633 }
634
635 - var middleContent = (
635 + const middleContent = (
636 <div>
637 <Middle>Hello</Middle>
638 <Bar>-</Bar>
@@ -640,7 +640,7 @@ describe('ReactIncremental', () => {
640 </div>
641 );
642
643 - var step0 = (
643 + const step0 = (
644 <div>
645 <Middle>Hi</Middle>
646 <Bar>{'Foo'}</Bar>
@@ -788,7 +788,7 @@ describe('ReactIncremental', () => {
788 });
789
790 xit('can reuse work if shouldComponentUpdate is false, after being preempted', () => {
791 - var ops = [];
791 + let ops = [];
792
793 function Bar(props) {
794 ops.push('Bar');
@@ -1110,9 +1110,9 @@ describe('ReactIncremental', () => {
1110 });
1111
1112 xit('can call sCU while resuming a partly mounted component', () => {
1113 - var ops = [];
1113 + let ops = [];
1114
1115 - var instances = new Set();
1115 + const instances = new Set();
1116
1117 class Bar extends React.Component {
1118 state = {y: 'A'};
@@ -1159,8 +1159,8 @@ describe('ReactIncremental', () => {
1159 });
1160
1161 xit('gets new props when setting state on a partly updated component', () => {
1162 - var ops = [];
1163 - var instances = [];
1162 + let ops = [];
1163 + const instances = [];
1164
1165 class Bar extends React.Component {
1166 state = {y: 'A'};
@@ -1227,7 +1227,7 @@ describe('ReactIncremental', () => {
1227 });
1228
1229 xit('calls componentWillMount twice if the initial render is aborted', () => {
1230 - var ops = [];
1230 + let ops = [];
1231
1232 class LifeCycle extends React.Component {
1233 state = {x: this.props.x};
@@ -1283,7 +1283,7 @@ describe('ReactIncremental', () => {
1283 });
1284
1285 xit('uses state set in componentWillMount even if initial render was aborted', () => {
1286 - var ops = [];
1286 + let ops = [];
1287
1288 class LifeCycle extends React.Component {
1289 constructor(props) {
@@ -1330,7 +1330,7 @@ describe('ReactIncremental', () => {
1330 });
1331
1332 xit('calls componentWill* twice if an update render is aborted', () => {
1333 - var ops = [];
1333 + let ops = [];
1334
1335 class LifeCycle extends React.Component {
1336 componentWillMount() {
@@ -1417,9 +1417,9 @@ describe('ReactIncremental', () => {
1417 });
1418
1419 xit('does not call componentWillReceiveProps for state-only updates', () => {
1420 - var ops = [];
1420 + let ops = [];
1421
1422 - var instances = [];
1422 + const instances = [];
1423
1424 class LifeCycle extends React.Component {
1425 state = {x: 0};
@@ -1566,7 +1566,7 @@ describe('ReactIncremental', () => {
1566 });
1567
1568 xit('skips will/DidUpdate when bailing unless an update was already in progress', () => {
1569 - var ops = [];
1569 + let ops = [];
1570
1571 class LifeCycle extends React.Component {
1572 componentWillMount() {
@@ -1662,8 +1662,8 @@ describe('ReactIncremental', () => {
1662 });
1663
1664 it('can nest batchedUpdates', () => {
1665 - var ops = [];
1666 - var instance;
1665 + let ops = [];
1666 + let instance;
1667
1668 class Foo extends React.Component {
1669 state = {n: 0};
@@ -1704,8 +1704,8 @@ describe('ReactIncremental', () => {
1704 });
1705
1706 it('can handle if setState callback throws', () => {
1707 - var ops = [];
1708 - var instance;
1707 + let ops = [];
1708 + let instance;
1709
1710 class Foo extends React.Component {
1711 state = {n: 0};
@@ -1740,7 +1740,7 @@ describe('ReactIncremental', () => {
1740 });
1741
1742 it('merges and masks context', () => {
1743 - var ops = [];
1743 + const ops = [];
1744
1745 class Intl extends React.Component {
1746 static childContextTypes = {
@@ -1896,7 +1896,7 @@ describe('ReactIncremental', () => {
1896 });
1897
1898 it('does not leak own context into context provider', () => {
1899 - var ops = [];
1899 + const ops = [];
1900 class Recurse extends React.Component {
1901 static contextTypes = {
1902 n: PropTypes.number,
@@ -1927,7 +1927,7 @@ describe('ReactIncremental', () => {
1927 });
1928
1929 it('provides context when reusing work', () => {
1930 - var ops = [];
1930 + const ops = [];
1931
1932 class Intl extends React.Component {
1933 static childContextTypes = {
@@ -1984,8 +1984,8 @@ describe('ReactIncremental', () => {
1984 });
1985
1986 it('reads context when setState is below the provider', () => {
1987 - var ops = [];
1988 - var statefulInst;
1987 + const ops = [];
1988 + let statefulInst;
1989
1990 class Intl extends React.Component {
1991 static childContextTypes = {
@@ -2074,8 +2074,8 @@ describe('ReactIncremental', () => {
2074 });
2075
2076 it('reads context when setState is above the provider', () => {
2077 - var ops = [];
2078 - var statefulInst;
2077 + const ops = [];
2078 + let statefulInst;
2079
2080 class Intl extends React.Component {
2081 static childContextTypes = {
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.js
+14 -14
@@ -9,9 +9,9 @@
9
10 'use strict';
11
12 -var PropTypes;
13 -var React;
14 -var ReactNoop;
12 +let PropTypes;
13 +let React;
14 +let ReactNoop;
15
16 describe('ReactIncrementalErrorHandling', () => {
17 beforeEach(() => {
@@ -60,7 +60,7 @@ describe('ReactIncrementalErrorHandling', () => {
60 });
61
62 it('catches render error in a boundary during partial deferred mounting', () => {
63 - var ops = [];
63 + const ops = [];
64 class ErrorBoundary extends React.Component {
65 state = {error: null};
66 componentDidCatch(error) {
@@ -105,7 +105,7 @@ describe('ReactIncrementalErrorHandling', () => {
105 });
106
107 it('catches render error in a boundary during synchronous mounting', () => {
108 - var ops = [];
108 + const ops = [];
109 class ErrorBoundary extends React.Component {
110 state = {error: null};
111 componentDidCatch(error) {
@@ -147,7 +147,7 @@ describe('ReactIncrementalErrorHandling', () => {
147 });
148
149 it('catches render error in a boundary during batched mounting', () => {
150 - var ops = [];
150 + const ops = [];
151 class ErrorBoundary extends React.Component {
152 state = {error: null};
153 componentDidCatch(error) {
@@ -190,7 +190,7 @@ describe('ReactIncrementalErrorHandling', () => {
190 });
191
192 it('propagates an error from a noop error boundary during full deferred mounting', () => {
193 - var ops = [];
193 + const ops = [];
194 class RethrowErrorBoundary extends React.Component {
195 componentDidCatch(error) {
196 ops.push('RethrowErrorBoundary componentDidCatch');
@@ -225,7 +225,7 @@ describe('ReactIncrementalErrorHandling', () => {
225 });
226
227 it('propagates an error from a noop error boundary during partial deferred mounting', () => {
228 - var ops = [];
228 + const ops = [];
229 class RethrowErrorBoundary extends React.Component {
230 componentDidCatch(error) {
231 ops.push('RethrowErrorBoundary componentDidCatch');
@@ -263,7 +263,7 @@ describe('ReactIncrementalErrorHandling', () => {
263 });
264
265 it('propagates an error from a noop error boundary during synchronous mounting', () => {
266 - var ops = [];
266 + const ops = [];
267 class RethrowErrorBoundary extends React.Component {
268 componentDidCatch(error) {
269 ops.push('RethrowErrorBoundary componentDidCatch');
@@ -298,7 +298,7 @@ describe('ReactIncrementalErrorHandling', () => {
298 });
299
300 it('propagates an error from a noop error boundary during batched mounting', () => {
301 - var ops = [];
301 + const ops = [];
302 class RethrowErrorBoundary extends React.Component {
303 componentDidCatch(error) {
304 ops.push('RethrowErrorBoundary componentDidCatch');
@@ -380,7 +380,7 @@ describe('ReactIncrementalErrorHandling', () => {
380 });
381
382 it('can schedule updates after uncaught error in render on mount', () => {
383 - var ops = [];
383 + let ops = [];
384
385 function BrokenRender() {
386 ops.push('BrokenRender');
@@ -405,7 +405,7 @@ describe('ReactIncrementalErrorHandling', () => {
405 });
406
407 it('can schedule updates after uncaught error in render on update', () => {
408 - var ops = [];
408 + let ops = [];
409
410 function BrokenRender(props) {
411 ops.push('BrokenRender');
@@ -437,7 +437,7 @@ describe('ReactIncrementalErrorHandling', () => {
437 });
438
439 it('can schedule updates after uncaught error during umounting', () => {
440 - var ops = [];
440 + let ops = [];
441
442 class BrokenComponentWillUnmount extends React.Component {
443 render() {
@@ -895,7 +895,7 @@ describe('ReactIncrementalErrorHandling', () => {
895 });
896
897 it('does not interrupt unmounting if detaching a ref throws', () => {
898 - var ops = [];
898 + let ops = [];
899
900 class Bar extends React.Component {
901 componentWillUnmount() {
packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.internal.js
+2 -2
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 describe('ReactIncrementalErrorLogging', () => {
16 beforeEach(() => {
packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js
+2 -2
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 describe('ReactIncrementalReflection', () => {
16 beforeEach(() => {
packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js
+4 -4
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 describe('ReactIncrementalScheduling', () => {
16 beforeEach(() => {
@@ -112,8 +112,8 @@ describe('ReactIncrementalScheduling', () => {
112 });
113
114 it('schedules sync updates when inside componentDidMount/Update', () => {
115 - var instance;
116 - var ops = [];
115 + let instance;
116 + let ops = [];
117
118 class Foo extends React.Component {
119 state = {tick: 0};
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
+13 -13
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 describe('ReactIncrementalSideEffects', () => {
16 beforeEach(() => {
@@ -305,7 +305,7 @@ describe('ReactIncrementalSideEffects', () => {
305 return <span prop={props.children} />;
306 }
307
308 - var middleContent = (
308 + const middleContent = (
309 <div>
310 <Bar>Hello</Bar>
311 <Bar>World</Bar>
@@ -515,7 +515,7 @@ describe('ReactIncrementalSideEffects', () => {
515 ),
516 ),
517 ]);
518 - var innerSpanA = ReactNoop.getChildren()[0].children[1].children[1];
518 + const innerSpanA = ReactNoop.getChildren()[0].children[1].children[1];
519 ReactNoop.render(<Foo tick={2} idx={1} />);
520 ReactNoop.flushDeferredPri(30 + 25);
521 expect(ReactNoop.getChildren()).toEqual([
@@ -541,7 +541,7 @@ describe('ReactIncrementalSideEffects', () => {
541 ),
542 ]);
543
544 - var innerSpanB = ReactNoop.getChildren()[0].children[1].children[1];
544 + const innerSpanB = ReactNoop.getChildren()[0].children[1].children[1];
545 // This should have been an update to an existing instance, not recreation.
546 // We verify that by ensuring that the child instance was the same as
547 // before.
@@ -549,7 +549,7 @@ describe('ReactIncrementalSideEffects', () => {
549 });
550
551 xit('can defer side-effects and reuse them later - complex', function() {
552 - var ops = [];
552 + let ops = [];
553
554 class Bar extends React.Component {
555 shouldComponentUpdate(nextProps) {
@@ -693,9 +693,9 @@ describe('ReactIncrementalSideEffects', () => {
693 });
694
695 it('deprioritizes setStates that happens within a deprioritized tree', () => {
696 - var ops = [];
696 + let ops = [];
697
698 - var barInstances = [];
698 + const barInstances = [];
699
700 class Bar extends React.Component {
701 constructor() {
@@ -851,7 +851,7 @@ describe('ReactIncrementalSideEffects', () => {
851 // TODO: Test that callbacks are not lost if an update is preempted.
852
853 it('calls componentWillUnmount after a deletion, even if nested', () => {
854 - var ops = [];
854 + const ops = [];
855
856 class Bar extends React.Component {
857 componentWillUnmount() {
@@ -911,7 +911,7 @@ describe('ReactIncrementalSideEffects', () => {
911 });
912
913 it('calls componentDidMount/Update after insertion/update', () => {
914 - var ops = [];
914 + let ops = [];
915
916 class Bar extends React.Component {
917 componentDidMount() {
@@ -987,9 +987,9 @@ describe('ReactIncrementalSideEffects', () => {
987
988 it('invokes ref callbacks after insertion/update/unmount', () => {
989 spyOnDev(console, 'error');
990 - var classInstance = null;
990 + let classInstance = null;
991
992 - var ops = [];
992 + let ops = [];
993
994 class ClassComponent extends React.Component {
995 render() {
@@ -1060,7 +1060,7 @@ describe('ReactIncrementalSideEffects', () => {
1060 // expected way for aborted and resumed render life-cycles.
1061
1062 it('supports string refs', () => {
1063 - var fooInstance = null;
1063 + let fooInstance = null;
1064
1065 class Bar extends React.Component {
1066 componentDidMount() {
packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.js
+3 -3
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 describe('ReactIncrementalTriangle', () => {
16 beforeEach(() => {
@@ -359,7 +359,7 @@ describe('ReactIncrementalTriangle', () => {
359 simulate(...actions);
360 } catch (e) {
361 console.error(
362 - `Triangle fuzz tester error! Copy and paste the following line into the test suite:
362 + `Triangle fuzz tester error! Copy and paste the following line into the test suite:
363 ${formatActions(actions)}
364 `,
365 );
packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js
+2 -2
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 describe('ReactIncrementalUpdates', () => {
16 beforeEach(() => {
packages/react-reconciler/src/__tests__/ReactPersistent-test.internal.js
+13 -13
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14 let ReactPortal;
15
16 describe('ReactPersistent', () => {
@@ -62,12 +62,12 @@ describe('ReactPersistent', () => {
62
63 render(<Foo text="Hello" />);
64 ReactNoop.flush();
65 - var originalChildren = getChildren();
65 + const originalChildren = getChildren();
66 expect(originalChildren).toEqual([div(span())]);
67
68 render(<Foo text="World" />);
69 ReactNoop.flush();
70 - var newChildren = getChildren();
70 + const newChildren = getChildren();
71 expect(newChildren).toEqual([div(span(), span())]);
72
73 expect(originalChildren).toEqual([div(span())]);
@@ -96,12 +96,12 @@ describe('ReactPersistent', () => {
96
97 render(<Foo text="Hello" />);
98 ReactNoop.flush();
99 - var originalChildren = getChildren();
99 + const originalChildren = getChildren();
100 expect(originalChildren).toEqual([div(span('Hello'))]);
101
102 render(<Foo text="World" />);
103 ReactNoop.flush();
104 - var newChildren = getChildren();
104 + const newChildren = getChildren();
105 expect(newChildren).toEqual([div(span('Hello'), span('World'))]);
106
107 expect(originalChildren).toEqual([div(span('Hello'))]);
@@ -122,12 +122,12 @@ describe('ReactPersistent', () => {
122
123 render(<Foo text="Hello" />);
124 ReactNoop.flush();
125 - var originalChildren = getChildren();
125 + const originalChildren = getChildren();
126 expect(originalChildren).toEqual([div('Hello', span())]);
127
128 render(<Foo text="World" />);
129 ReactNoop.flush();
130 - var newChildren = getChildren();
130 + const newChildren = getChildren();
131 expect(newChildren).toEqual([div('World', span())]);
132
133 expect(originalChildren).toEqual([div('Hello', span())]);
@@ -170,9 +170,9 @@ describe('ReactPersistent', () => {
170
171 expect(emptyPortalChildSet).toEqual([]);
172
173 - var originalChildren = getChildren();
173 + const originalChildren = getChildren();
174 expect(originalChildren).toEqual([div()]);
175 - var originalPortalChildren = portalContainer.children;
175 + const originalPortalChildren = portalContainer.children;
176 expect(originalPortalChildren).toEqual([div(span())]);
177
178 render(
@@ -186,9 +186,9 @@ describe('ReactPersistent', () => {
186 );
187 ReactNoop.flush();
188
189 - var newChildren = getChildren();
189 + const newChildren = getChildren();
190 expect(newChildren).toEqual([div()]);
191 - var newPortalChildren = portalContainer.children;
191 + const newPortalChildren = portalContainer.children;
192 expect(newPortalChildren).toEqual([div(span(), 'Hello ', 'World')]);
193
194 expect(originalChildren).toEqual([div()]);
@@ -203,7 +203,7 @@ describe('ReactPersistent', () => {
203 render(<Parent />);
204 ReactNoop.flush();
205
206 - var clearedPortalChildren = portalContainer.children;
206 + const clearedPortalChildren = portalContainer.children;
207 expect(clearedPortalChildren).toEqual([]);
208
209 // The original is unchanged.
packages/react-reconciler/src/__tests__/ReactTopLevelFragment-test.js
+15 -15
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 // This is a new feature in Fiber so I put it in its own test file. It could
16 // probably move to one of the other test files once it is official.
@@ -30,7 +30,7 @@ describe('ReactTopLevelFragment', function() {
30 });
31
32 it('should preserve state when switching from a single child', function() {
33 - var instance = null;
33 + let instance = null;
34
35 class Stateful extends React.Component {
36 render() {
@@ -49,20 +49,20 @@ describe('ReactTopLevelFragment', function() {
49 ReactNoop.render(<Fragment />);
50 ReactNoop.flush();
51
52 - var instanceA = instance;
52 + const instanceA = instance;
53
54 expect(instanceA).not.toBe(null);
55
56 ReactNoop.render(<Fragment condition={true} />);
57 ReactNoop.flush();
58
59 - var instanceB = instance;
59 + const instanceB = instance;
60
61 expect(instanceB).toBe(instanceA);
62 });
63
64 it('should not preserve state when switching to a nested array', function() {
65 - var instance = null;
65 + let instance = null;
66
67 class Stateful extends React.Component {
68 render() {
@@ -81,20 +81,20 @@ describe('ReactTopLevelFragment', function() {
81 ReactNoop.render(<Fragment />);
82 ReactNoop.flush();
83
84 - var instanceA = instance;
84 + const instanceA = instance;
85
86 expect(instanceA).not.toBe(null);
87
88 ReactNoop.render(<Fragment condition={true} />);
89 ReactNoop.flush();
90
91 - var instanceB = instance;
91 + const instanceB = instance;
92
93 expect(instanceB).not.toBe(instanceA);
94 });
95
96 it('preserves state if an implicit key slot switches from/to null', function() {
97 - var instance = null;
97 + let instance = null;
98
99 class Stateful extends React.Component {
100 render() {
@@ -111,27 +111,27 @@ describe('ReactTopLevelFragment', function() {
111 ReactNoop.render(<Fragment />);
112 ReactNoop.flush();
113
114 - var instanceA = instance;
114 + const instanceA = instance;
115
116 expect(instanceA).not.toBe(null);
117
118 ReactNoop.render(<Fragment condition={true} />);
119 ReactNoop.flush();
120
121 - var instanceB = instance;
121 + const instanceB = instance;
122
123 expect(instanceB).toBe(instanceA);
124
125 ReactNoop.render(<Fragment condition={false} />);
126 ReactNoop.flush();
127
128 - var instanceC = instance;
128 + const instanceC = instance;
129
130 expect(instanceC === instanceA).toBe(true);
131 });
132
133 it('should preserve state in a reorder', function() {
134 - var instance = null;
134 + let instance = null;
135
136 class Stateful extends React.Component {
137 render() {
@@ -148,14 +148,14 @@ describe('ReactTopLevelFragment', function() {
148 ReactNoop.render(<Fragment />);
149 ReactNoop.flush();
150
151 - var instanceA = instance;
151 + const instanceA = instance;
152
153 expect(instanceA).not.toBe(null);
154
155 ReactNoop.render(<Fragment condition={true} />);
156 ReactNoop.flush();
157
158 - var instanceB = instance;
158 + const instanceB = instance;
159
160 expect(instanceB).toBe(instanceA);
161 });
packages/react-reconciler/src/__tests__/ReactTopLevelText-test.js
+2 -2
@@ -9,8 +9,8 @@
9
10 'use strict';
11
12 -var React;
13 -var ReactNoop;
12 +let React;
13 +let ReactNoop;
14
15 // This is a new feature in Fiber so I put it in its own test file. It could
16 // probably move to one of the other test files once it is official.