Skip to content

Commit

Permalink
Tweak comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed May 15, 2018
1 parent 025d867 commit d758960
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 4 additions & 0 deletions packages/events/TopLevelEventTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ type RNTopLevelEventType =

export opaque type DOMTopLevelEventType = string;

// Do not uses the below two methods directly!
// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
// (It is the only module that is allowed to access these methods.)

export function unsafeCastStringToDOMTopLevelType(
topLevelType: string,
): DOMTopLevelEventType {
Expand Down
13 changes: 5 additions & 8 deletions packages/react-dom/src/events/DOMTopLevelEventTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ import {
import getVendorPrefixedEventName from './getVendorPrefixedEventName';

/**
* To identify top level events in react-dom, we use constants defined by this
* module. Those are completely opaque to every other module but we rely on them
* being the raw DOM event names inside this module. This allows us to build a
* very efficient mapping from top level identifiers to the raw event type.
*
* The use of an `opaque` flow type makes sure that we can only access the value
* of a constant in this module.
* To identify top level events in ReactDOM, we use constants defined by this
* module. This is the only module that uses the unsafe* methods to express
* that the constants actually correspond to the browser event names. This lets
* us save some bundle size by avoiding a top level type -> event name map.
* The rest of ReactDOM code should import top level types from this file.
*/

export const TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
export const TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(
getVendorPrefixedEventName('animationend'),
Expand Down

0 comments on commit d758960

Please sign in to comment.