react-test-renderer 15.5.0 → 15.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/lib/ReactShallowRenderer.js +6 -0
  2. package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
  3. package/lib/shallow/AutoFocusUtils.js +23 -0
  4. package/lib/shallow/BeforeInputEventPlugin.js +384 -0
  5. package/lib/shallow/CSSProperty.js +147 -0
  6. package/lib/shallow/CSSPropertyOperations.js +208 -0
  7. package/lib/shallow/CallbackQueue.js +118 -0
  8. package/lib/shallow/ChangeEventPlugin.js +345 -0
  9. package/lib/shallow/DOMChildrenOperations.js +224 -0
  10. package/lib/shallow/DOMLazyTree.js +117 -0
  11. package/lib/shallow/DOMNamespaces.js +19 -0
  12. package/lib/shallow/DOMProperty.js +209 -0
  13. package/lib/shallow/DOMPropertyOperations.js +236 -0
  14. package/lib/shallow/Danger.js +47 -0
  15. package/lib/shallow/DefaultEventPluginOrder.js +25 -0
  16. package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
  17. package/lib/shallow/EventConstants.js +91 -0
  18. package/lib/shallow/EventPluginHub.js +277 -0
  19. package/lib/shallow/EventPluginRegistry.js +254 -0
  20. package/lib/shallow/EventPluginUtils.js +225 -0
  21. package/lib/shallow/EventPropagators.js +133 -0
  22. package/lib/shallow/FallbackCompositionState.js +94 -0
  23. package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
  24. package/lib/shallow/KeyEscapeUtils.js +58 -0
  25. package/lib/shallow/LinkedValueUtils.js +137 -0
  26. package/lib/shallow/PluginModuleType.js +12 -0
  27. package/lib/shallow/PooledClass.js +111 -0
  28. package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
  29. package/lib/shallow/ReactChildFiber.js +243 -0
  30. package/lib/shallow/ReactChildReconciler.js +153 -0
  31. package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
  32. package/lib/shallow/ReactComponentEnvironment.js +45 -0
  33. package/lib/shallow/ReactCompositeComponent.js +901 -0
  34. package/lib/shallow/ReactCoroutine.js +80 -0
  35. package/lib/shallow/ReactDOM.js +110 -0
  36. package/lib/shallow/ReactDOMComponent.js +1000 -0
  37. package/lib/shallow/ReactDOMComponentFlags.js +17 -0
  38. package/lib/shallow/ReactDOMComponentTree.js +194 -0
  39. package/lib/shallow/ReactDOMContainerInfo.js +32 -0
  40. package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
  41. package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
  42. package/lib/shallow/ReactDOMFiber.js +97 -0
  43. package/lib/shallow/ReactDOMIDOperations.js +33 -0
  44. package/lib/shallow/ReactDOMInput.js +284 -0
  45. package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
  46. package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
  47. package/lib/shallow/ReactDOMOption.js +122 -0
  48. package/lib/shallow/ReactDOMSelect.js +199 -0
  49. package/lib/shallow/ReactDOMSelection.js +211 -0
  50. package/lib/shallow/ReactDOMServer.js +25 -0
  51. package/lib/shallow/ReactDOMTextComponent.js +163 -0
  52. package/lib/shallow/ReactDOMTextarea.js +159 -0
  53. package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
  54. package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
  55. package/lib/shallow/ReactDebugTool.js +358 -0
  56. package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
  57. package/lib/shallow/ReactDefaultInjection.js +85 -0
  58. package/lib/shallow/ReactElementSymbol.js +19 -0
  59. package/lib/shallow/ReactEmptyComponent.js +29 -0
  60. package/lib/shallow/ReactErrorUtils.js +75 -0
  61. package/lib/shallow/ReactEventEmitterMixin.js +32 -0
  62. package/lib/shallow/ReactEventListener.js +154 -0
  63. package/lib/shallow/ReactFeatureFlags.js +21 -0
  64. package/lib/shallow/ReactFiber.js +190 -0
  65. package/lib/shallow/ReactFiberBeginWork.js +380 -0
  66. package/lib/shallow/ReactFiberCommitWork.js +78 -0
  67. package/lib/shallow/ReactFiberCompleteWork.js +208 -0
  68. package/lib/shallow/ReactFiberReconciler.js +64 -0
  69. package/lib/shallow/ReactFiberRoot.js +29 -0
  70. package/lib/shallow/ReactFiberScheduler.js +331 -0
  71. package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
  72. package/lib/shallow/ReactHostComponent.js +67 -0
  73. package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
  74. package/lib/shallow/ReactInjection.js +33 -0
  75. package/lib/shallow/ReactInputSelection.js +123 -0
  76. package/lib/shallow/ReactInstanceMap.js +47 -0
  77. package/lib/shallow/ReactInstanceType.js +12 -0
  78. package/lib/shallow/ReactInstrumentation.js +23 -0
  79. package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
  80. package/lib/shallow/ReactMarkupChecksum.js +49 -0
  81. package/lib/shallow/ReactMount.js +537 -0
  82. package/lib/shallow/ReactMultiChild.js +449 -0
  83. package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
  84. package/lib/shallow/ReactNodeTypes.js +39 -0
  85. package/lib/shallow/ReactOwner.js +93 -0
  86. package/lib/shallow/ReactPerf.js +500 -0
  87. package/lib/shallow/ReactPriorityLevel.js +20 -0
  88. package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
  89. package/lib/shallow/ReactPropTypeLocations.js +12 -0
  90. package/lib/shallow/ReactPropTypesSecret.js +16 -0
  91. package/lib/shallow/ReactReconcileTransaction.js +177 -0
  92. package/lib/shallow/ReactReconciler.js +167 -0
  93. package/lib/shallow/ReactRef.js +88 -0
  94. package/lib/shallow/ReactReifiedYield.js +30 -0
  95. package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
  96. package/lib/shallow/ReactServerRendering.js +89 -0
  97. package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
  98. package/lib/shallow/ReactServerUpdateQueue.js +138 -0
  99. package/lib/shallow/ReactShallowRenderer.js +150 -0
  100. package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
  101. package/lib/shallow/ReactSyntheticEventType.js +14 -0
  102. package/lib/shallow/ReactTestEmptyComponent.js +36 -0
  103. package/lib/shallow/ReactTestMount.js +131 -0
  104. package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
  105. package/lib/shallow/ReactTestRenderer.js +139 -0
  106. package/lib/shallow/ReactTestTextComponent.js +40 -0
  107. package/lib/shallow/ReactTypeOfWork.js +23 -0
  108. package/lib/shallow/ReactTypes.js +12 -0
  109. package/lib/shallow/ReactUpdateQueue.js +235 -0
  110. package/lib/shallow/ReactUpdates.js +250 -0
  111. package/lib/shallow/ReactVersion.js +13 -0
  112. package/lib/shallow/ResponderEventPlugin.js +507 -0
  113. package/lib/shallow/ResponderSyntheticEvent.js +38 -0
  114. package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
  115. package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
  116. package/lib/shallow/SelectEventPlugin.js +190 -0
  117. package/lib/shallow/SimpleEventPlugin.js +227 -0
  118. package/lib/shallow/SyntheticAnimationEvent.js +38 -0
  119. package/lib/shallow/SyntheticClipboardEvent.js +37 -0
  120. package/lib/shallow/SyntheticCompositionEvent.js +35 -0
  121. package/lib/shallow/SyntheticDragEvent.js +35 -0
  122. package/lib/shallow/SyntheticEvent.js +267 -0
  123. package/lib/shallow/SyntheticFocusEvent.js +35 -0
  124. package/lib/shallow/SyntheticInputEvent.js +36 -0
  125. package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
  126. package/lib/shallow/SyntheticMouseEvent.js +71 -0
  127. package/lib/shallow/SyntheticTouchEvent.js +44 -0
  128. package/lib/shallow/SyntheticTransitionEvent.js +38 -0
  129. package/lib/shallow/SyntheticUIEvent.js +58 -0
  130. package/lib/shallow/SyntheticWheelEvent.js +53 -0
  131. package/lib/shallow/TapEventPlugin.js +115 -0
  132. package/lib/shallow/TouchHistoryMath.js +98 -0
  133. package/lib/shallow/Transaction.js +224 -0
  134. package/lib/shallow/ViewportMetrics.js +26 -0
  135. package/lib/shallow/accumulate.js +45 -0
  136. package/lib/shallow/accumulateInto.js +57 -0
  137. package/lib/shallow/adler32.js +43 -0
  138. package/lib/shallow/canDefineProperty.js +25 -0
  139. package/lib/shallow/checkReactTypeSpec.js +86 -0
  140. package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
  141. package/lib/shallow/dangerousStyleValue.js +78 -0
  142. package/lib/shallow/deprecated.js +56 -0
  143. package/lib/shallow/escapeTextContentForBrowser.js +122 -0
  144. package/lib/shallow/findDOMNode.js +59 -0
  145. package/lib/shallow/flattenChildren.js +75 -0
  146. package/lib/shallow/forEachAccumulated.js +30 -0
  147. package/lib/shallow/getEventCharCode.js +49 -0
  148. package/lib/shallow/getEventKey.js +101 -0
  149. package/lib/shallow/getEventModifierState.js +42 -0
  150. package/lib/shallow/getEventTarget.js +34 -0
  151. package/lib/shallow/getHostComponentFromComposite.js +29 -0
  152. package/lib/shallow/getIteratorFn.js +40 -0
  153. package/lib/shallow/getNodeForCharacterOffset.js +73 -0
  154. package/lib/shallow/getTextContentAccessor.js +32 -0
  155. package/lib/shallow/getVendorPrefixedEventName.js +100 -0
  156. package/lib/shallow/instantiateReactComponent.js +128 -0
  157. package/lib/shallow/isEventSupported.js +59 -0
  158. package/lib/shallow/isTextInputElement.js +50 -0
  159. package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
  160. package/lib/shallow/reactProdInvariant.js +38 -0
  161. package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
  162. package/lib/shallow/setInnerHTML.js +97 -0
  163. package/lib/shallow/setTextContent.js +51 -0
  164. package/lib/shallow/shouldUpdateReactComponent.js +41 -0
  165. package/lib/shallow/traverseAllChildren.js +175 -0
  166. package/lib/shallow/validateDOMNesting.js +376 -0
  167. package/package.json +1 -1
  168. package/shallow.js +1 -1
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
16
+ var EventListener = require('fbjs/lib/EventListener');
17
+ var EventPropagators = require('./EventPropagators');
18
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
19
+ var SyntheticAnimationEvent = require('./SyntheticAnimationEvent');
20
+ var SyntheticClipboardEvent = require('./SyntheticClipboardEvent');
21
+ var SyntheticEvent = require('./SyntheticEvent');
22
+ var SyntheticFocusEvent = require('./SyntheticFocusEvent');
23
+ var SyntheticKeyboardEvent = require('./SyntheticKeyboardEvent');
24
+ var SyntheticMouseEvent = require('./SyntheticMouseEvent');
25
+ var SyntheticDragEvent = require('./SyntheticDragEvent');
26
+ var SyntheticTouchEvent = require('./SyntheticTouchEvent');
27
+ var SyntheticTransitionEvent = require('./SyntheticTransitionEvent');
28
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
29
+ var SyntheticWheelEvent = require('./SyntheticWheelEvent');
30
+
31
+ var emptyFunction = require('fbjs/lib/emptyFunction');
32
+ var getEventCharCode = require('./getEventCharCode');
33
+ var invariant = require('fbjs/lib/invariant');
34
+
35
+ /**
36
+ * Turns
37
+ * ['abort', ...]
38
+ * into
39
+ * eventTypes = {
40
+ * 'abort': {
41
+ * phasedRegistrationNames: {
42
+ * bubbled: 'onAbort',
43
+ * captured: 'onAbortCapture',
44
+ * },
45
+ * dependencies: ['topAbort'],
46
+ * },
47
+ * ...
48
+ * };
49
+ * topLevelEventsToDispatchConfig = {
50
+ * 'topAbort': { sameConfig }
51
+ * };
52
+ */
53
+ var eventTypes = {};
54
+ var topLevelEventsToDispatchConfig = {};
55
+ ['abort', 'animationEnd', 'animationIteration', 'animationStart', 'blur', 'canPlay', 'canPlayThrough', 'click', 'contextMenu', 'copy', 'cut', 'doubleClick', 'drag', 'dragEnd', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'dragStart', 'drop', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'focus', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'mouseDown', 'mouseMove', 'mouseOut', 'mouseOver', 'mouseUp', 'paste', 'pause', 'play', 'playing', 'progress', 'rateChange', 'reset', 'scroll', 'seeked', 'seeking', 'stalled', 'submit', 'suspend', 'timeUpdate', 'touchCancel', 'touchEnd', 'touchMove', 'touchStart', 'transitionEnd', 'volumeChange', 'waiting', 'wheel'].forEach(function (event) {
56
+ var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
57
+ var onEvent = 'on' + capitalizedEvent;
58
+ var topEvent = 'top' + capitalizedEvent;
59
+
60
+ var type = {
61
+ phasedRegistrationNames: {
62
+ bubbled: onEvent,
63
+ captured: onEvent + 'Capture'
64
+ },
65
+ dependencies: [topEvent]
66
+ };
67
+ eventTypes[event] = type;
68
+ topLevelEventsToDispatchConfig[topEvent] = type;
69
+ });
70
+
71
+ var onClickListeners = {};
72
+
73
+ function getDictionaryKey(inst) {
74
+ // Prevents V8 performance issue:
75
+ // https://github.com/facebook/react/pull/7232
76
+ return '.' + inst._rootNodeID;
77
+ }
78
+
79
+ function isInteractive(tag) {
80
+ return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
81
+ }
82
+
83
+ var SimpleEventPlugin = {
84
+
85
+ eventTypes: eventTypes,
86
+
87
+ extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
88
+ var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
89
+ if (!dispatchConfig) {
90
+ return null;
91
+ }
92
+ var EventConstructor;
93
+ switch (topLevelType) {
94
+ case 'topAbort':
95
+ case 'topCanPlay':
96
+ case 'topCanPlayThrough':
97
+ case 'topDurationChange':
98
+ case 'topEmptied':
99
+ case 'topEncrypted':
100
+ case 'topEnded':
101
+ case 'topError':
102
+ case 'topInput':
103
+ case 'topInvalid':
104
+ case 'topLoad':
105
+ case 'topLoadedData':
106
+ case 'topLoadedMetadata':
107
+ case 'topLoadStart':
108
+ case 'topPause':
109
+ case 'topPlay':
110
+ case 'topPlaying':
111
+ case 'topProgress':
112
+ case 'topRateChange':
113
+ case 'topReset':
114
+ case 'topSeeked':
115
+ case 'topSeeking':
116
+ case 'topStalled':
117
+ case 'topSubmit':
118
+ case 'topSuspend':
119
+ case 'topTimeUpdate':
120
+ case 'topVolumeChange':
121
+ case 'topWaiting':
122
+ // HTML Events
123
+ // @see http://www.w3.org/TR/html5/index.html#events-0
124
+ EventConstructor = SyntheticEvent;
125
+ break;
126
+ case 'topKeyPress':
127
+ // Firefox creates a keypress event for function keys too. This removes
128
+ // the unwanted keypress events. Enter is however both printable and
129
+ // non-printable. One would expect Tab to be as well (but it isn't).
130
+ if (getEventCharCode(nativeEvent) === 0) {
131
+ return null;
132
+ }
133
+ /* falls through */
134
+ case 'topKeyDown':
135
+ case 'topKeyUp':
136
+ EventConstructor = SyntheticKeyboardEvent;
137
+ break;
138
+ case 'topBlur':
139
+ case 'topFocus':
140
+ EventConstructor = SyntheticFocusEvent;
141
+ break;
142
+ case 'topClick':
143
+ // Firefox creates a click event on right mouse clicks. This removes the
144
+ // unwanted click events.
145
+ if (nativeEvent.button === 2) {
146
+ return null;
147
+ }
148
+ /* falls through */
149
+ case 'topDoubleClick':
150
+ case 'topMouseDown':
151
+ case 'topMouseMove':
152
+ case 'topMouseUp':
153
+ // TODO: Disabled elements should not respond to mouse events
154
+ /* falls through */
155
+ case 'topMouseOut':
156
+ case 'topMouseOver':
157
+ case 'topContextMenu':
158
+ EventConstructor = SyntheticMouseEvent;
159
+ break;
160
+ case 'topDrag':
161
+ case 'topDragEnd':
162
+ case 'topDragEnter':
163
+ case 'topDragExit':
164
+ case 'topDragLeave':
165
+ case 'topDragOver':
166
+ case 'topDragStart':
167
+ case 'topDrop':
168
+ EventConstructor = SyntheticDragEvent;
169
+ break;
170
+ case 'topTouchCancel':
171
+ case 'topTouchEnd':
172
+ case 'topTouchMove':
173
+ case 'topTouchStart':
174
+ EventConstructor = SyntheticTouchEvent;
175
+ break;
176
+ case 'topAnimationEnd':
177
+ case 'topAnimationIteration':
178
+ case 'topAnimationStart':
179
+ EventConstructor = SyntheticAnimationEvent;
180
+ break;
181
+ case 'topTransitionEnd':
182
+ EventConstructor = SyntheticTransitionEvent;
183
+ break;
184
+ case 'topScroll':
185
+ EventConstructor = SyntheticUIEvent;
186
+ break;
187
+ case 'topWheel':
188
+ EventConstructor = SyntheticWheelEvent;
189
+ break;
190
+ case 'topCopy':
191
+ case 'topCut':
192
+ case 'topPaste':
193
+ EventConstructor = SyntheticClipboardEvent;
194
+ break;
195
+ }
196
+ !EventConstructor ? process.env.NODE_ENV !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : _prodInvariant('86', topLevelType) : void 0;
197
+ var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
198
+ EventPropagators.accumulateTwoPhaseDispatches(event);
199
+ return event;
200
+ },
201
+
202
+ didPutListener: function (inst, registrationName, listener) {
203
+ // Mobile Safari does not fire properly bubble click events on
204
+ // non-interactive elements, which means delegated click listeners do not
205
+ // fire. The workaround for this bug involves attaching an empty click
206
+ // listener on the target node.
207
+ // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
208
+ if (registrationName === 'onClick' && !isInteractive(inst._tag)) {
209
+ var key = getDictionaryKey(inst);
210
+ var node = ReactDOMComponentTree.getNodeFromInstance(inst);
211
+ if (!onClickListeners[key]) {
212
+ onClickListeners[key] = EventListener.listen(node, 'click', emptyFunction);
213
+ }
214
+ }
215
+ },
216
+
217
+ willDeleteListener: function (inst, registrationName) {
218
+ if (registrationName === 'onClick' && !isInteractive(inst._tag)) {
219
+ var key = getDictionaryKey(inst);
220
+ onClickListeners[key].remove();
221
+ delete onClickListeners[key];
222
+ }
223
+ }
224
+
225
+ };
226
+
227
+ module.exports = SimpleEventPlugin;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var SyntheticEvent = require('./SyntheticEvent');
14
+
15
+ /**
16
+ * @interface Event
17
+ * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
18
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
19
+ */
20
+ var AnimationEventInterface = {
21
+ animationName: null,
22
+ elapsedTime: null,
23
+ pseudoElement: null
24
+ };
25
+
26
+ /**
27
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
28
+ * @param {string} dispatchMarker Marker identifying the event target.
29
+ * @param {object} nativeEvent Native browser event.
30
+ * @extends {SyntheticEvent}
31
+ */
32
+ function SyntheticAnimationEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
33
+ return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
34
+ }
35
+
36
+ SyntheticEvent.augmentClass(SyntheticAnimationEvent, AnimationEventInterface);
37
+
38
+ module.exports = SyntheticAnimationEvent;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var SyntheticEvent = require('./SyntheticEvent');
14
+
15
+ /**
16
+ * @interface Event
17
+ * @see http://www.w3.org/TR/clipboard-apis/
18
+ */
19
+ var ClipboardEventInterface = {
20
+ clipboardData: function (event) {
21
+ return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
22
+ }
23
+ };
24
+
25
+ /**
26
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
27
+ * @param {string} dispatchMarker Marker identifying the event target.
28
+ * @param {object} nativeEvent Native browser event.
29
+ * @extends {SyntheticUIEvent}
30
+ */
31
+ function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
32
+ return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
33
+ }
34
+
35
+ SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
36
+
37
+ module.exports = SyntheticClipboardEvent;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var SyntheticEvent = require('./SyntheticEvent');
14
+
15
+ /**
16
+ * @interface Event
17
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
18
+ */
19
+ var CompositionEventInterface = {
20
+ data: null
21
+ };
22
+
23
+ /**
24
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
25
+ * @param {string} dispatchMarker Marker identifying the event target.
26
+ * @param {object} nativeEvent Native browser event.
27
+ * @extends {SyntheticUIEvent}
28
+ */
29
+ function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
30
+ return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
31
+ }
32
+
33
+ SyntheticEvent.augmentClass(SyntheticCompositionEvent, CompositionEventInterface);
34
+
35
+ module.exports = SyntheticCompositionEvent;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var SyntheticMouseEvent = require('./SyntheticMouseEvent');
14
+
15
+ /**
16
+ * @interface DragEvent
17
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
18
+ */
19
+ var DragEventInterface = {
20
+ dataTransfer: null
21
+ };
22
+
23
+ /**
24
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
25
+ * @param {string} dispatchMarker Marker identifying the event target.
26
+ * @param {object} nativeEvent Native browser event.
27
+ * @extends {SyntheticUIEvent}
28
+ */
29
+ function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
30
+ return SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
31
+ }
32
+
33
+ SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
34
+
35
+ module.exports = SyntheticDragEvent;
@@ -0,0 +1,267 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _assign = require('object-assign');
14
+
15
+ var PooledClass = require('./PooledClass');
16
+
17
+ var emptyFunction = require('fbjs/lib/emptyFunction');
18
+ var warning = require('fbjs/lib/warning');
19
+
20
+ var didWarnForAddedNewProperty = false;
21
+ var isProxySupported = typeof Proxy === 'function';
22
+
23
+ var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
24
+
25
+ /**
26
+ * @interface Event
27
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
28
+ */
29
+ var EventInterface = {
30
+ type: null,
31
+ target: null,
32
+ // currentTarget is set when dispatching; no use in copying it here
33
+ currentTarget: emptyFunction.thatReturnsNull,
34
+ eventPhase: null,
35
+ bubbles: null,
36
+ cancelable: null,
37
+ timeStamp: function (event) {
38
+ return event.timeStamp || Date.now();
39
+ },
40
+ defaultPrevented: null,
41
+ isTrusted: null
42
+ };
43
+
44
+ /**
45
+ * Synthetic events are dispatched by event plugins, typically in response to a
46
+ * top-level event delegation handler.
47
+ *
48
+ * These systems should generally use pooling to reduce the frequency of garbage
49
+ * collection. The system should check `isPersistent` to determine whether the
50
+ * event should be released into the pool after being dispatched. Users that
51
+ * need a persisted event should invoke `persist`.
52
+ *
53
+ * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
54
+ * normalizing browser quirks. Subclasses do not necessarily have to implement a
55
+ * DOM interface; custom application-specific events can also subclass this.
56
+ *
57
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
58
+ * @param {*} targetInst Marker identifying the event target.
59
+ * @param {object} nativeEvent Native browser event.
60
+ * @param {DOMEventTarget} nativeEventTarget Target node.
61
+ */
62
+ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
63
+ if (process.env.NODE_ENV !== 'production') {
64
+ // these have a getter/setter for warnings
65
+ delete this.nativeEvent;
66
+ delete this.preventDefault;
67
+ delete this.stopPropagation;
68
+ }
69
+
70
+ this.dispatchConfig = dispatchConfig;
71
+ this._targetInst = targetInst;
72
+ this.nativeEvent = nativeEvent;
73
+
74
+ var Interface = this.constructor.Interface;
75
+ for (var propName in Interface) {
76
+ if (!Interface.hasOwnProperty(propName)) {
77
+ continue;
78
+ }
79
+ if (process.env.NODE_ENV !== 'production') {
80
+ delete this[propName]; // this has a getter/setter for warnings
81
+ }
82
+ var normalize = Interface[propName];
83
+ if (normalize) {
84
+ this[propName] = normalize(nativeEvent);
85
+ } else {
86
+ if (propName === 'target') {
87
+ this.target = nativeEventTarget;
88
+ } else {
89
+ this[propName] = nativeEvent[propName];
90
+ }
91
+ }
92
+ }
93
+
94
+ var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
95
+ if (defaultPrevented) {
96
+ this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
97
+ } else {
98
+ this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
99
+ }
100
+ this.isPropagationStopped = emptyFunction.thatReturnsFalse;
101
+ return this;
102
+ }
103
+
104
+ _assign(SyntheticEvent.prototype, {
105
+
106
+ preventDefault: function () {
107
+ this.defaultPrevented = true;
108
+ var event = this.nativeEvent;
109
+ if (!event) {
110
+ return;
111
+ }
112
+
113
+ if (event.preventDefault) {
114
+ event.preventDefault();
115
+ } else if (typeof event.returnValue !== 'unknown') {
116
+ // eslint-disable-line valid-typeof
117
+ event.returnValue = false;
118
+ }
119
+ this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
120
+ },
121
+
122
+ stopPropagation: function () {
123
+ var event = this.nativeEvent;
124
+ if (!event) {
125
+ return;
126
+ }
127
+
128
+ if (event.stopPropagation) {
129
+ event.stopPropagation();
130
+ } else if (typeof event.cancelBubble !== 'unknown') {
131
+ // eslint-disable-line valid-typeof
132
+ // The ChangeEventPlugin registers a "propertychange" event for
133
+ // IE. This event does not support bubbling or cancelling, and
134
+ // any references to cancelBubble throw "Member not found". A
135
+ // typeof check of "unknown" circumvents this issue (and is also
136
+ // IE specific).
137
+ event.cancelBubble = true;
138
+ }
139
+
140
+ this.isPropagationStopped = emptyFunction.thatReturnsTrue;
141
+ },
142
+
143
+ /**
144
+ * We release all dispatched `SyntheticEvent`s after each event loop, adding
145
+ * them back into the pool. This allows a way to hold onto a reference that
146
+ * won't be added back into the pool.
147
+ */
148
+ persist: function () {
149
+ this.isPersistent = emptyFunction.thatReturnsTrue;
150
+ },
151
+
152
+ /**
153
+ * Checks if this event should be released back into the pool.
154
+ *
155
+ * @return {boolean} True if this should not be released, false otherwise.
156
+ */
157
+ isPersistent: emptyFunction.thatReturnsFalse,
158
+
159
+ /**
160
+ * `PooledClass` looks for `destructor` on each instance it releases.
161
+ */
162
+ destructor: function () {
163
+ var Interface = this.constructor.Interface;
164
+ for (var propName in Interface) {
165
+ if (process.env.NODE_ENV !== 'production') {
166
+ Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
167
+ } else {
168
+ this[propName] = null;
169
+ }
170
+ }
171
+ for (var i = 0; i < shouldBeReleasedProperties.length; i++) {
172
+ this[shouldBeReleasedProperties[i]] = null;
173
+ }
174
+ if (process.env.NODE_ENV !== 'production') {
175
+ Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
176
+ Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction));
177
+ Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction));
178
+ }
179
+ }
180
+
181
+ });
182
+
183
+ SyntheticEvent.Interface = EventInterface;
184
+
185
+ if (process.env.NODE_ENV !== 'production') {
186
+ if (isProxySupported) {
187
+ /*eslint-disable no-func-assign */
188
+ SyntheticEvent = new Proxy(SyntheticEvent, {
189
+ construct: function (target, args) {
190
+ return this.apply(target, Object.create(target.prototype), args);
191
+ },
192
+ apply: function (constructor, that, args) {
193
+ return new Proxy(constructor.apply(that, args), {
194
+ set: function (target, prop, value) {
195
+ if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) {
196
+ process.env.NODE_ENV !== 'production' ? warning(didWarnForAddedNewProperty || target.isPersistent(), 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re adding a new property in the synthetic event object. ' + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.') : void 0;
197
+ didWarnForAddedNewProperty = true;
198
+ }
199
+ target[prop] = value;
200
+ return true;
201
+ }
202
+ });
203
+ }
204
+ });
205
+ /*eslint-enable no-func-assign */
206
+ }
207
+ }
208
+ /**
209
+ * Helper to reduce boilerplate when creating subclasses.
210
+ *
211
+ * @param {function} Class
212
+ * @param {?object} Interface
213
+ */
214
+ SyntheticEvent.augmentClass = function (Class, Interface) {
215
+ var Super = this;
216
+
217
+ var E = function () {};
218
+ E.prototype = Super.prototype;
219
+ var prototype = new E();
220
+
221
+ _assign(prototype, Class.prototype);
222
+ Class.prototype = prototype;
223
+ Class.prototype.constructor = Class;
224
+
225
+ Class.Interface = _assign({}, Super.Interface, Interface);
226
+ Class.augmentClass = Super.augmentClass;
227
+
228
+ PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
229
+ };
230
+
231
+ PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler);
232
+
233
+ module.exports = SyntheticEvent;
234
+
235
+ /**
236
+ * Helper to nullify syntheticEvent instance properties when destructing
237
+ *
238
+ * @param {object} SyntheticEvent
239
+ * @param {String} propName
240
+ * @return {object} defineProperty object
241
+ */
242
+ function getPooledWarningPropertyDefinition(propName, getVal) {
243
+ var isFunction = typeof getVal === 'function';
244
+ return {
245
+ configurable: true,
246
+ set: set,
247
+ get: get
248
+ };
249
+
250
+ function set(val) {
251
+ var action = isFunction ? 'setting the method' : 'setting the property';
252
+ warn(action, 'This is effectively a no-op');
253
+ return val;
254
+ }
255
+
256
+ function get() {
257
+ var action = isFunction ? 'accessing the method' : 'accessing the property';
258
+ var result = isFunction ? 'This is a no-op function' : 'This is set to null';
259
+ warn(action, result);
260
+ return getVal;
261
+ }
262
+
263
+ function warn(action, result) {
264
+ var warningCondition = false;
265
+ process.env.NODE_ENV !== 'production' ? warning(warningCondition, 'This synthetic event is reused for performance reasons. If you\'re seeing this, ' + 'you\'re %s `%s` on a released/nullified synthetic event. %s. ' + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
266
+ }
267
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
14
+
15
+ /**
16
+ * @interface FocusEvent
17
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
18
+ */
19
+ var FocusEventInterface = {
20
+ relatedTarget: null
21
+ };
22
+
23
+ /**
24
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
25
+ * @param {string} dispatchMarker Marker identifying the event target.
26
+ * @param {object} nativeEvent Native browser event.
27
+ * @extends {SyntheticUIEvent}
28
+ */
29
+ function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
30
+ return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
31
+ }
32
+
33
+ SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
34
+
35
+ module.exports = SyntheticFocusEvent;