@samitouri / QOS-React / commits / d758960116

Tweak comments

Dan Abramov committed May 15, 2018 at 15:42 UTC d758960116b3ea3a3bd3dfe2f297d5e680fe9ff5
2 files changed +9 -8
packages/events/TopLevelEventTypes.js
+4
@@ -20,6 +20,10 @@ type RNTopLevelEventType =
20
21 export opaque type DOMTopLevelEventType = string;
22
23 +// Do not uses the below two methods directly!
24 +// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
25 +// (It is the only module that is allowed to access these methods.)
26 +
27 export function unsafeCastStringToDOMTopLevelType(
28 topLevelType: string,
29 ): DOMTopLevelEventType {
packages/react-dom/src/events/DOMTopLevelEventTypes.js
+5 -8
@@ -16,15 +16,12 @@ import {
16 import getVendorPrefixedEventName from './getVendorPrefixedEventName';
17
18 /**
19 - * To identify top level events in react-dom, we use constants defined by this
20 - * module. Those are completely opaque to every other module but we rely on them
21 - * being the raw DOM event names inside this module. This allows us to build a
22 - * very efficient mapping from top level identifiers to the raw event type.
23 - *
24 - * The use of an `opaque` flow type makes sure that we can only access the value
25 - * of a constant in this module.
19 + * To identify top level events in ReactDOM, we use constants defined by this
20 + * module. This is the only module that uses the unsafe* methods to express
21 + * that the constants actually correspond to the browser event names. This lets
22 + * us save some bundle size by avoiding a top level type -> event name map.
23 + * The rest of ReactDOM code should import top level types from this file.
24 */
27 -
25 export const TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
26 export const TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(
27 getVendorPrefixedEventName('animationend'),