From 02afcecd643603ec47d882424c48c9ff5663e067 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Sun, 28 Aug 2016 10:52:33 -0700 Subject: [PATCH] Remove keyMirror in PropagationPhases See rationale in https://www.facebook.com/groups/2003630259862046/permalink/2097088000516271/ --- src/renderers/shared/stack/event/EventConstants.js | 3 +-- src/renderers/shared/stack/event/EventPropagators.js | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/renderers/shared/stack/event/EventConstants.js b/src/renderers/shared/stack/event/EventConstants.js index 84a9e9d486ff..b74df197a4a2 100644 --- a/src/renderers/shared/stack/event/EventConstants.js +++ b/src/renderers/shared/stack/event/EventConstants.js @@ -13,7 +13,7 @@ var keyMirror = require('keyMirror'); -var PropagationPhases = keyMirror({bubbled: null, captured: null}); +export type PropagationPhases = 'bubbled' | 'captured'; /** * Types of raw signals from the browser caught at the top level. @@ -91,7 +91,6 @@ var topLevelTypes = keyMirror({ var EventConstants = { topLevelTypes: topLevelTypes, - PropagationPhases: PropagationPhases, }; module.exports = EventConstants; diff --git a/src/renderers/shared/stack/event/EventPropagators.js b/src/renderers/shared/stack/event/EventPropagators.js index 95cc188261ec..3aa40994dd74 100644 --- a/src/renderers/shared/stack/event/EventPropagators.js +++ b/src/renderers/shared/stack/event/EventPropagators.js @@ -11,7 +11,6 @@ 'use strict'; -var EventConstants = require('EventConstants'); var EventPluginHub = require('EventPluginHub'); var EventPluginUtils = require('EventPluginUtils'); @@ -19,14 +18,15 @@ var accumulateInto = require('accumulateInto'); var forEachAccumulated = require('forEachAccumulated'); var warning = require('warning'); -var PropagationPhases = EventConstants.PropagationPhases; +import type { PropagationPhases } from 'EventConstants'; + var getListener = EventPluginHub.getListener; /** * Some event types have a notion of different registration names for different * "phases" of propagation. This finds listeners by a given phase. */ -function listenerAtPhase(inst, event, propagationPhase) { +function listenerAtPhase(inst, event, propagationPhase: PropagationPhases) { var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; return getListener(inst, registrationName); @@ -45,7 +45,7 @@ function accumulateDirectionalDispatches(inst, upwards, event) { 'Dispatching inst must not be null' ); } - var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured; + var phase = upwards ? 'bubbled' : 'captured'; var listener = listenerAtPhase(inst, event, phase); if (listener) { event._dispatchListeners =