Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

no more vars (convert var to let/const) #11699

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/events/EventPluginHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type {AnyNativeEvent} from './PluginModuleType';
* Internal queue of events that have accumulated their dispatches and are
* waiting to have their dispatches executed.
*/
var eventQueue: ?(Array<ReactSyntheticEvent> | ReactSyntheticEvent) = null;
let eventQueue: ?(Array<ReactSyntheticEvent> | ReactSyntheticEvent) = null;

/**
* Dispatches an event and releases it back into the pool, unless persistent.
Expand All @@ -39,7 +39,7 @@ var eventQueue: ?(Array<ReactSyntheticEvent> | ReactSyntheticEvent) = null;
* @param {boolean} simulated If the event is simulated (changes exn behavior)
* @private
*/
var executeDispatchesAndRelease = function(
const executeDispatchesAndRelease = function(
event: ReactSyntheticEvent,
simulated: boolean,
) {
Expand All @@ -51,10 +51,10 @@ var executeDispatchesAndRelease = function(
}
}
};
var executeDispatchesAndReleaseSimulated = function(e) {
const executeDispatchesAndReleaseSimulated = function(e) {
return executeDispatchesAndRelease(e, true);
};
var executeDispatchesAndReleaseTopLevel = function(e) {
const executeDispatchesAndReleaseTopLevel = function(e) {
return executeDispatchesAndRelease(e, false);
};

Expand Down Expand Up @@ -130,7 +130,7 @@ export const injection = {
* @return {?function} The stored callback.
*/
export function getListener(inst: Fiber, registrationName: string) {
var listener;
let listener;

// TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
// live here; needs to be moved to a better place soon
Expand Down Expand Up @@ -170,12 +170,12 @@ export function extractEvents(
nativeEvent: AnyNativeEvent,
nativeEventTarget: EventTarget,
) {
var events;
for (var i = 0; i < plugins.length; i++) {
let events;
for (let i = 0; i < plugins.length; i++) {
// Not every plugin in the ordering may be loaded at runtime.
var possiblePlugin: PluginModule<AnyNativeEvent> = plugins[i];
const possiblePlugin: PluginModule<AnyNativeEvent> = plugins[i];
if (possiblePlugin) {
var extractedEvents = possiblePlugin.extractEvents(
const extractedEvents = possiblePlugin.extractEvents(
topLevelType,
targetInst,
nativeEvent,
Expand Down Expand Up @@ -212,7 +212,7 @@ export function enqueueEvents(
export function processEventQueue(simulated: boolean) {
// Set `eventQueue` to null before processing it so that we can tell if more
// events get enqueued while processing.
var processingEventQueue = eventQueue;
const processingEventQueue = eventQueue;
eventQueue = null;

if (!processingEventQueue) {
Expand Down
28 changes: 14 additions & 14 deletions packages/events/EventPluginRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ type EventPluginOrder = null | Array<PluginName>;
/**
* Injectable ordering of event plugins.
*/
var eventPluginOrder: EventPluginOrder = null;
let eventPluginOrder: EventPluginOrder = null;

/**
* Injectable mapping from names to event plugin modules.
*/
var namesToPlugins: NamesToPlugins = {};
const namesToPlugins: NamesToPlugins = {};

/**
* Recomputes the plugin list using the injected plugins and plugin ordering.
Expand All @@ -39,9 +39,9 @@ function recomputePluginOrdering(): void {
// Wait until an `eventPluginOrder` is injected.
return;
}
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName];
var pluginIndex = eventPluginOrder.indexOf(pluginName);
for (const pluginName in namesToPlugins) {
const pluginModule = namesToPlugins[pluginName];
const pluginIndex = eventPluginOrder.indexOf(pluginName);
invariant(
pluginIndex > -1,
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
Expand All @@ -58,8 +58,8 @@ function recomputePluginOrdering(): void {
pluginName,
);
plugins[pluginIndex] = pluginModule;
var publishedEvents = pluginModule.eventTypes;
for (var eventName in publishedEvents) {
const publishedEvents = pluginModule.eventTypes;
for (const eventName in publishedEvents) {
invariant(
publishEventForPlugin(
publishedEvents[eventName],
Expand Down Expand Up @@ -95,11 +95,11 @@ function publishEventForPlugin(
);
eventNameDispatchConfigs[eventName] = dispatchConfig;

var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
const phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
if (phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
for (const phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
const phasedRegistrationName = phasedRegistrationNames[phaseName];
publishRegistrationName(
phasedRegistrationName,
pluginModule,
Expand Down Expand Up @@ -142,7 +142,7 @@ function publishRegistrationName(
pluginModule.eventTypes[eventName].dependencies;

if (__DEV__) {
var lowerCasedName = registrationName.toLowerCase();
const lowerCasedName = registrationName.toLowerCase();
possibleRegistrationNames[lowerCasedName] = registrationName;

if (registrationName === 'onDoubleClick') {
Expand Down Expand Up @@ -221,12 +221,12 @@ export function injectEventPluginOrder(
export function injectEventPluginsByName(
injectedNamesToPlugins: NamesToPlugins,
): void {
var isOrderingDirty = false;
for (var pluginName in injectedNamesToPlugins) {
let isOrderingDirty = false;
for (const pluginName in injectedNamesToPlugins) {
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
continue;
}
var pluginModule = injectedNamesToPlugins[pluginName];
const pluginModule = injectedNamesToPlugins[pluginName];
if (
!namesToPlugins.hasOwnProperty(pluginName) ||
namesToPlugins[pluginName] !== pluginModule
Expand Down
36 changes: 18 additions & 18 deletions packages/events/EventPluginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ export function isStartish(topLevelType) {
return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart';
}

var validateEventDispatches;
let validateEventDispatches;
if (__DEV__) {
validateEventDispatches = function(event) {
var dispatchListeners = event._dispatchListeners;
var dispatchInstances = event._dispatchInstances;
const dispatchListeners = event._dispatchListeners;
const dispatchInstances = event._dispatchInstances;

var listenersIsArr = Array.isArray(dispatchListeners);
var listenersLen = listenersIsArr
const listenersIsArr = Array.isArray(dispatchListeners);
const listenersLen = listenersIsArr
? dispatchListeners.length
: dispatchListeners ? 1 : 0;

var instancesIsArr = Array.isArray(dispatchInstances);
var instancesLen = instancesIsArr
const instancesIsArr = Array.isArray(dispatchInstances);
const instancesLen = instancesIsArr
? dispatchInstances.length
: dispatchInstances ? 1 : 0;

Expand All @@ -76,7 +76,7 @@ if (__DEV__) {
* @param {*} inst Internal component instance
*/
function executeDispatch(event, simulated, listener, inst) {
var type = event.type || 'unknown-event';
const type = event.type || 'unknown-event';
event.currentTarget = getNodeFromInstance(inst);
ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError(
type,
Expand All @@ -91,13 +91,13 @@ function executeDispatch(event, simulated, listener, inst) {
* Standard/simple iteration through an event's collected dispatches.
*/
export function executeDispatchesInOrder(event, simulated) {
var dispatchListeners = event._dispatchListeners;
var dispatchInstances = event._dispatchInstances;
const dispatchListeners = event._dispatchListeners;
const dispatchInstances = event._dispatchInstances;
if (__DEV__) {
validateEventDispatches(event);
}
if (Array.isArray(dispatchListeners)) {
for (var i = 0; i < dispatchListeners.length; i++) {
for (let i = 0; i < dispatchListeners.length; i++) {
if (event.isPropagationStopped()) {
break;
}
Expand All @@ -124,13 +124,13 @@ export function executeDispatchesInOrder(event, simulated) {
* true, or null if no listener returned true.
*/
function executeDispatchesInOrderStopAtTrueImpl(event) {
var dispatchListeners = event._dispatchListeners;
var dispatchInstances = event._dispatchInstances;
const dispatchListeners = event._dispatchListeners;
const dispatchInstances = event._dispatchInstances;
if (__DEV__) {
validateEventDispatches(event);
}
if (Array.isArray(dispatchListeners)) {
for (var i = 0; i < dispatchListeners.length; i++) {
for (let i = 0; i < dispatchListeners.length; i++) {
if (event.isPropagationStopped()) {
break;
}
Expand All @@ -151,7 +151,7 @@ function executeDispatchesInOrderStopAtTrueImpl(event) {
* @see executeDispatchesInOrderStopAtTrueImpl
*/
export function executeDispatchesInOrderStopAtTrue(event) {
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
const ret = executeDispatchesInOrderStopAtTrueImpl(event);
event._dispatchInstances = null;
event._dispatchListeners = null;
return ret;
Expand All @@ -170,16 +170,16 @@ export function executeDirectDispatch(event) {
if (__DEV__) {
validateEventDispatches(event);
}
var dispatchListener = event._dispatchListeners;
var dispatchInstance = event._dispatchInstances;
const dispatchListener = event._dispatchListeners;
const dispatchInstance = event._dispatchInstances;
invariant(
!Array.isArray(dispatchListener),
'executeDirectDispatch(...): Invalid `event`.',
);
event.currentTarget = dispatchListener
? getNodeFromInstance(dispatchInstance)
: null;
var res = dispatchListener ? dispatchListener(event) : null;
const res = dispatchListener ? dispatchListener(event) : null;
event.currentTarget = null;
event._dispatchListeners = null;
event._dispatchInstances = null;
Expand Down
10 changes: 5 additions & 5 deletions packages/events/EventPropagators.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type PropagationPhases = 'bubbled' | 'captured';
* "phases" of propagation. This finds listeners by a given phase.
*/
function listenerAtPhase(inst, event, propagationPhase: PropagationPhases) {
var registrationName =
const registrationName =
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
return getListener(inst, registrationName);
}
Expand All @@ -48,7 +48,7 @@ function accumulateDirectionalDispatches(inst, phase, event) {
if (__DEV__) {
warning(inst, 'Dispatching inst must not be null');
}
var listener = listenerAtPhase(inst, event, phase);
const listener = listenerAtPhase(inst, event, phase);
if (listener) {
event._dispatchListeners = accumulateInto(
event._dispatchListeners,
Expand Down Expand Up @@ -76,8 +76,8 @@ function accumulateTwoPhaseDispatchesSingle(event) {
*/
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
var targetInst = event._targetInst;
var parentInst = targetInst ? getParentInstance(targetInst) : null;
const targetInst = event._targetInst;
const parentInst = targetInst ? getParentInstance(targetInst) : null;
traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
}
}
Expand All @@ -90,7 +90,7 @@ function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
function accumulateDispatches(inst, ignoredDirection, event) {
if (inst && event && event.dispatchConfig.registrationName) {
var registrationName = event.dispatchConfig.registrationName;
var listener = getListener(inst, registrationName);
const listener = getListener(inst, registrationName);
if (listener) {
event._dispatchListeners = accumulateInto(
event._dispatchListeners,
Expand Down
16 changes: 8 additions & 8 deletions packages/events/ReactControlledComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ import {

// Use to restore controlled state after a change event has fired.

var fiberHostComponent = null;
let fiberHostComponent = null;

var ReactControlledComponentInjection = {
const ReactControlledComponentInjection = {
injectFiberControlledHostComponent: function(hostComponentImpl) {
// The fiber implementation doesn't use dynamic dispatch so we need to
// inject the implementation.
fiberHostComponent = hostComponentImpl;
},
};

var restoreTarget = null;
var restoreQueue = null;
let restoreTarget = null;
let restoreQueue = null;

function restoreStateOfTarget(target) {
// We perform this translation at the end of the event loop so that we
// always receive the correct fiber here
var internalInstance = getInstanceFromNode(target);
const internalInstance = getInstanceFromNode(target);
if (!internalInstance) {
// Unmounted
return;
Expand Down Expand Up @@ -67,14 +67,14 @@ export function restoreStateIfNeeded() {
if (!restoreTarget) {
return;
}
var target = restoreTarget;
var queuedTargets = restoreQueue;
const target = restoreTarget;
const queuedTargets = restoreQueue;
restoreTarget = null;
restoreQueue = null;

restoreStateOfTarget(target);
if (queuedTargets) {
for (var i = 0; i < queuedTargets.length; i++) {
for (let i = 0; i < queuedTargets.length; i++) {
restoreStateOfTarget(queuedTargets[i]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/events/ReactEventEmitterMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function handleTopLevel(
nativeEvent,
nativeEventTarget,
) {
var events = extractEvents(
const events = extractEvents(
topLevelType,
targetInst,
nativeEvent,
Expand Down
6 changes: 3 additions & 3 deletions packages/events/ReactGenericBatching.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {restoreStateIfNeeded} from './ReactControlledComponent';
// scheduled work and instead do synchronous work.

// Defaults
var fiberBatchedUpdates = function(fn, bookkeeping) {
let fiberBatchedUpdates = function(fn, bookkeeping) {
return fn(bookkeeping);
};

var isNestingBatched = false;
let isNestingBatched = false;
export function batchedUpdates(fn, bookkeeping) {
if (isNestingBatched) {
// If we are currently inside another batch, we need to wait until it
Expand All @@ -39,7 +39,7 @@ export function batchedUpdates(fn, bookkeeping) {
}
}

var ReactGenericBatchingInjection = {
const ReactGenericBatchingInjection = {
injectFiberBatchedUpdates: function(_batchedUpdates) {
fiberBatchedUpdates = _batchedUpdates;
},
Expand Down
Loading