Skip to content
Merged
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
3 changes: 1 addition & 2 deletions src/renderers/shared/stack/event/EventConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -91,7 +91,6 @@ var topLevelTypes = keyMirror({

var EventConstants = {
topLevelTypes: topLevelTypes,
PropagationPhases: PropagationPhases,
};

module.exports = EventConstants;
8 changes: 4 additions & 4 deletions src/renderers/shared/stack/event/EventPropagators.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@

'use strict';

var EventConstants = require('EventConstants');
var EventPluginHub = require('EventPluginHub');
var EventPluginUtils = require('EventPluginUtils');

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];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vjeux

To be specific, the problem is on this line.
GCC will crush lines like these:

{
  abort: {
    phasedRegistrationNames: {
      bubbled: keyOf({onAbort: true}),
      captured: keyOf({onAbortCapture: true}),
    },
  },
}

into

{
  a: {
    b: {
      c: keyOf({e: true}),
      d: keyOf({f: true}),
    },
  },
}

However, phase will be a full string:

var phase = upwards ? 'bubbled' : 'captured';

and so

 var registrationName =
      event.dispatchConfig.phasedRegistrationNames[propagationPhase];            

will give you undefined.

return getListener(inst, registrationName);
Expand All @@ -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 =
Expand Down