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,225 @@
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 _prodInvariant = require('./reactProdInvariant');
14
+
15
+ var ReactErrorUtils = require('./ReactErrorUtils');
16
+
17
+ var invariant = require('fbjs/lib/invariant');
18
+ var warning = require('fbjs/lib/warning');
19
+
20
+ /**
21
+ * Injected dependencies:
22
+ */
23
+
24
+ /**
25
+ * - `ComponentTree`: [required] Module that can convert between React instances
26
+ * and actual node references.
27
+ */
28
+ var ComponentTree;
29
+ var TreeTraversal;
30
+ var injection = {
31
+ injectComponentTree: function (Injected) {
32
+ ComponentTree = Injected;
33
+ if (process.env.NODE_ENV !== 'production') {
34
+ process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
35
+ }
36
+ },
37
+ injectTreeTraversal: function (Injected) {
38
+ TreeTraversal = Injected;
39
+ if (process.env.NODE_ENV !== 'production') {
40
+ process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.isAncestor && Injected.getLowestCommonAncestor, 'EventPluginUtils.injection.injectTreeTraversal(...): Injected ' + 'module is missing isAncestor or getLowestCommonAncestor.') : void 0;
41
+ }
42
+ }
43
+ };
44
+
45
+ function isEndish(topLevelType) {
46
+ return topLevelType === 'topMouseUp' || topLevelType === 'topTouchEnd' || topLevelType === 'topTouchCancel';
47
+ }
48
+
49
+ function isMoveish(topLevelType) {
50
+ return topLevelType === 'topMouseMove' || topLevelType === 'topTouchMove';
51
+ }
52
+ function isStartish(topLevelType) {
53
+ return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart';
54
+ }
55
+
56
+ var validateEventDispatches;
57
+ if (process.env.NODE_ENV !== 'production') {
58
+ validateEventDispatches = function (event) {
59
+ var dispatchListeners = event._dispatchListeners;
60
+ var dispatchInstances = event._dispatchInstances;
61
+
62
+ var listenersIsArr = Array.isArray(dispatchListeners);
63
+ var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
64
+
65
+ var instancesIsArr = Array.isArray(dispatchInstances);
66
+ var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
67
+
68
+ process.env.NODE_ENV !== 'production' ? warning(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : void 0;
69
+ };
70
+ }
71
+
72
+ /**
73
+ * Dispatch the event to the listener.
74
+ * @param {SyntheticEvent} event SyntheticEvent to handle
75
+ * @param {boolean} simulated If the event is simulated (changes exn behavior)
76
+ * @param {function} listener Application-level callback
77
+ * @param {*} inst Internal component instance
78
+ */
79
+ function executeDispatch(event, simulated, listener, inst) {
80
+ var type = event.type || 'unknown-event';
81
+ event.currentTarget = EventPluginUtils.getNodeFromInstance(inst);
82
+ if (simulated) {
83
+ ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event);
84
+ } else {
85
+ ReactErrorUtils.invokeGuardedCallback(type, listener, event);
86
+ }
87
+ event.currentTarget = null;
88
+ }
89
+
90
+ /**
91
+ * Standard/simple iteration through an event's collected dispatches.
92
+ */
93
+ function executeDispatchesInOrder(event, simulated) {
94
+ var dispatchListeners = event._dispatchListeners;
95
+ var dispatchInstances = event._dispatchInstances;
96
+ if (process.env.NODE_ENV !== 'production') {
97
+ validateEventDispatches(event);
98
+ }
99
+ if (Array.isArray(dispatchListeners)) {
100
+ for (var i = 0; i < dispatchListeners.length; i++) {
101
+ if (event.isPropagationStopped()) {
102
+ break;
103
+ }
104
+ // Listeners and Instances are two parallel arrays that are always in sync.
105
+ executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]);
106
+ }
107
+ } else if (dispatchListeners) {
108
+ executeDispatch(event, simulated, dispatchListeners, dispatchInstances);
109
+ }
110
+ event._dispatchListeners = null;
111
+ event._dispatchInstances = null;
112
+ }
113
+
114
+ /**
115
+ * Standard/simple iteration through an event's collected dispatches, but stops
116
+ * at the first dispatch execution returning true, and returns that id.
117
+ *
118
+ * @return {?string} id of the first dispatch execution who's listener returns
119
+ * true, or null if no listener returned true.
120
+ */
121
+ function executeDispatchesInOrderStopAtTrueImpl(event) {
122
+ var dispatchListeners = event._dispatchListeners;
123
+ var dispatchInstances = event._dispatchInstances;
124
+ if (process.env.NODE_ENV !== 'production') {
125
+ validateEventDispatches(event);
126
+ }
127
+ if (Array.isArray(dispatchListeners)) {
128
+ for (var i = 0; i < dispatchListeners.length; i++) {
129
+ if (event.isPropagationStopped()) {
130
+ break;
131
+ }
132
+ // Listeners and Instances are two parallel arrays that are always in sync.
133
+ if (dispatchListeners[i](event, dispatchInstances[i])) {
134
+ return dispatchInstances[i];
135
+ }
136
+ }
137
+ } else if (dispatchListeners) {
138
+ if (dispatchListeners(event, dispatchInstances)) {
139
+ return dispatchInstances;
140
+ }
141
+ }
142
+ return null;
143
+ }
144
+
145
+ /**
146
+ * @see executeDispatchesInOrderStopAtTrueImpl
147
+ */
148
+ function executeDispatchesInOrderStopAtTrue(event) {
149
+ var ret = executeDispatchesInOrderStopAtTrueImpl(event);
150
+ event._dispatchInstances = null;
151
+ event._dispatchListeners = null;
152
+ return ret;
153
+ }
154
+
155
+ /**
156
+ * Execution of a "direct" dispatch - there must be at most one dispatch
157
+ * accumulated on the event or it is considered an error. It doesn't really make
158
+ * sense for an event with multiple dispatches (bubbled) to keep track of the
159
+ * return values at each dispatch execution, but it does tend to make sense when
160
+ * dealing with "direct" dispatches.
161
+ *
162
+ * @return {*} The return value of executing the single dispatch.
163
+ */
164
+ function executeDirectDispatch(event) {
165
+ if (process.env.NODE_ENV !== 'production') {
166
+ validateEventDispatches(event);
167
+ }
168
+ var dispatchListener = event._dispatchListeners;
169
+ var dispatchInstance = event._dispatchInstances;
170
+ !!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : _prodInvariant('103') : void 0;
171
+ event.currentTarget = dispatchListener ? EventPluginUtils.getNodeFromInstance(dispatchInstance) : null;
172
+ var res = dispatchListener ? dispatchListener(event) : null;
173
+ event.currentTarget = null;
174
+ event._dispatchListeners = null;
175
+ event._dispatchInstances = null;
176
+ return res;
177
+ }
178
+
179
+ /**
180
+ * @param {SyntheticEvent} event
181
+ * @return {boolean} True iff number of dispatches accumulated is greater than 0.
182
+ */
183
+ function hasDispatches(event) {
184
+ return !!event._dispatchListeners;
185
+ }
186
+
187
+ /**
188
+ * General utilities that are useful in creating custom Event Plugins.
189
+ */
190
+ var EventPluginUtils = {
191
+ isEndish: isEndish,
192
+ isMoveish: isMoveish,
193
+ isStartish: isStartish,
194
+
195
+ executeDirectDispatch: executeDirectDispatch,
196
+ executeDispatchesInOrder: executeDispatchesInOrder,
197
+ executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
198
+ hasDispatches: hasDispatches,
199
+
200
+ getInstanceFromNode: function (node) {
201
+ return ComponentTree.getInstanceFromNode(node);
202
+ },
203
+ getNodeFromInstance: function (node) {
204
+ return ComponentTree.getNodeFromInstance(node);
205
+ },
206
+ isAncestor: function (a, b) {
207
+ return TreeTraversal.isAncestor(a, b);
208
+ },
209
+ getLowestCommonAncestor: function (a, b) {
210
+ return TreeTraversal.getLowestCommonAncestor(a, b);
211
+ },
212
+ getParentInstance: function (inst) {
213
+ return TreeTraversal.getParentInstance(inst);
214
+ },
215
+ traverseTwoPhase: function (target, fn, arg) {
216
+ return TreeTraversal.traverseTwoPhase(target, fn, arg);
217
+ },
218
+ traverseEnterLeave: function (from, to, fn, argFrom, argTo) {
219
+ return TreeTraversal.traverseEnterLeave(from, to, fn, argFrom, argTo);
220
+ },
221
+
222
+ injection: injection
223
+ };
224
+
225
+ module.exports = EventPluginUtils;
@@ -0,0 +1,133 @@
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 EventPluginHub = require('./EventPluginHub');
14
+ var EventPluginUtils = require('./EventPluginUtils');
15
+
16
+ var accumulateInto = require('./accumulateInto');
17
+ var forEachAccumulated = require('./forEachAccumulated');
18
+ var warning = require('fbjs/lib/warning');
19
+
20
+ var getListener = EventPluginHub.getListener;
21
+
22
+ /**
23
+ * Some event types have a notion of different registration names for different
24
+ * "phases" of propagation. This finds listeners by a given phase.
25
+ */
26
+ function listenerAtPhase(inst, event, propagationPhase) {
27
+ var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
28
+ return getListener(inst, registrationName);
29
+ }
30
+
31
+ /**
32
+ * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
33
+ * here, allows us to not have to bind or create functions for each event.
34
+ * Mutating the event's members allows us to not have to create a wrapping
35
+ * "dispatch" object that pairs the event with the listener.
36
+ */
37
+ function accumulateDirectionalDispatches(inst, phase, event) {
38
+ if (process.env.NODE_ENV !== 'production') {
39
+ process.env.NODE_ENV !== 'production' ? warning(inst, 'Dispatching inst must not be null') : void 0;
40
+ }
41
+ var listener = listenerAtPhase(inst, event, phase);
42
+ if (listener) {
43
+ event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
44
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Collect dispatches (must be entirely collected before dispatching - see unit
50
+ * tests). Lazily allocate the array to conserve memory. We must loop through
51
+ * each event and perform the traversal for each one. We cannot perform a
52
+ * single traversal for the entire collection of events because each event may
53
+ * have a different target.
54
+ */
55
+ function accumulateTwoPhaseDispatchesSingle(event) {
56
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
57
+ EventPluginUtils.traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
63
+ */
64
+ function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
65
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
66
+ var targetInst = event._targetInst;
67
+ var parentInst = targetInst ? EventPluginUtils.getParentInstance(targetInst) : null;
68
+ EventPluginUtils.traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Accumulates without regard to direction, does not look for phased
74
+ * registration names. Same as `accumulateDirectDispatchesSingle` but without
75
+ * requiring that the `dispatchMarker` be the same as the dispatched ID.
76
+ */
77
+ function accumulateDispatches(inst, ignoredDirection, event) {
78
+ if (event && event.dispatchConfig.registrationName) {
79
+ var registrationName = event.dispatchConfig.registrationName;
80
+ var listener = getListener(inst, registrationName);
81
+ if (listener) {
82
+ event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
83
+ event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
84
+ }
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Accumulates dispatches on an `SyntheticEvent`, but only for the
90
+ * `dispatchMarker`.
91
+ * @param {SyntheticEvent} event
92
+ */
93
+ function accumulateDirectDispatchesSingle(event) {
94
+ if (event && event.dispatchConfig.registrationName) {
95
+ accumulateDispatches(event._targetInst, null, event);
96
+ }
97
+ }
98
+
99
+ function accumulateTwoPhaseDispatches(events) {
100
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
101
+ }
102
+
103
+ function accumulateTwoPhaseDispatchesSkipTarget(events) {
104
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
105
+ }
106
+
107
+ function accumulateEnterLeaveDispatches(leave, enter, from, to) {
108
+ EventPluginUtils.traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
109
+ }
110
+
111
+ function accumulateDirectDispatches(events) {
112
+ forEachAccumulated(events, accumulateDirectDispatchesSingle);
113
+ }
114
+
115
+ /**
116
+ * A small set of propagation patterns, each of which will accept a small amount
117
+ * of information, and generate a set of "dispatch ready event objects" - which
118
+ * are sets of events that have already been annotated with a set of dispatched
119
+ * listener functions/ids. The API is designed this way to discourage these
120
+ * propagation strategies from actually executing the dispatches, since we
121
+ * always want to collect the entire set of dispatches before executing event a
122
+ * single one.
123
+ *
124
+ * @constructor EventPropagators
125
+ */
126
+ var EventPropagators = {
127
+ accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
128
+ accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
129
+ accumulateDirectDispatches: accumulateDirectDispatches,
130
+ accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
131
+ };
132
+
133
+ module.exports = EventPropagators;
@@ -0,0 +1,94 @@
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 getTextContentAccessor = require('./getTextContentAccessor');
18
+
19
+ /**
20
+ * This helper class stores information about text content of a target node,
21
+ * allowing comparison of content before and after a given event.
22
+ *
23
+ * Identify the node where selection currently begins, then observe
24
+ * both its text content and its current position in the DOM. Since the
25
+ * browser may natively replace the target node during composition, we can
26
+ * use its position to find its replacement.
27
+ *
28
+ * @param {DOMEventTarget} root
29
+ */
30
+ function FallbackCompositionState(root) {
31
+ this._root = root;
32
+ this._startText = this.getText();
33
+ this._fallbackText = null;
34
+ }
35
+
36
+ _assign(FallbackCompositionState.prototype, {
37
+ destructor: function () {
38
+ this._root = null;
39
+ this._startText = null;
40
+ this._fallbackText = null;
41
+ },
42
+
43
+ /**
44
+ * Get current text of input.
45
+ *
46
+ * @return {string}
47
+ */
48
+ getText: function () {
49
+ if ('value' in this._root) {
50
+ return this._root.value;
51
+ }
52
+ return this._root[getTextContentAccessor()];
53
+ },
54
+
55
+ /**
56
+ * Determine the differing substring between the initially stored
57
+ * text content and the current content.
58
+ *
59
+ * @return {string}
60
+ */
61
+ getData: function () {
62
+ if (this._fallbackText) {
63
+ return this._fallbackText;
64
+ }
65
+
66
+ var start;
67
+ var startValue = this._startText;
68
+ var startLength = startValue.length;
69
+ var end;
70
+ var endValue = this.getText();
71
+ var endLength = endValue.length;
72
+
73
+ for (start = 0; start < startLength; start++) {
74
+ if (startValue[start] !== endValue[start]) {
75
+ break;
76
+ }
77
+ }
78
+
79
+ var minEnd = startLength - start;
80
+ for (end = 1; end <= minEnd; end++) {
81
+ if (startValue[startLength - end] !== endValue[endLength - end]) {
82
+ break;
83
+ }
84
+ }
85
+
86
+ var sliceTail = end > 1 ? 1 - end : undefined;
87
+ this._fallbackText = endValue.slice(start, sliceTail);
88
+ return this._fallbackText;
89
+ }
90
+ });
91
+
92
+ PooledClass.addPoolingTo(FallbackCompositionState);
93
+
94
+ module.exports = FallbackCompositionState;
@@ -0,0 +1,235 @@
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 DOMProperty = require('./DOMProperty');
14
+
15
+ var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
16
+ var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
17
+ var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
18
+ var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
19
+ var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
20
+
21
+ var HTMLDOMPropertyConfig = {
22
+ isCustomAttribute: RegExp.prototype.test.bind(new RegExp('^(data|aria)-[' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$')),
23
+ Properties: {
24
+ /**
25
+ * Standard Properties
26
+ */
27
+ accept: 0,
28
+ acceptCharset: 0,
29
+ accessKey: 0,
30
+ action: 0,
31
+ allowFullScreen: HAS_BOOLEAN_VALUE,
32
+ allowTransparency: 0,
33
+ alt: 0,
34
+ // specifies target context for links with `preload` type
35
+ as: 0,
36
+ async: HAS_BOOLEAN_VALUE,
37
+ autoComplete: 0,
38
+ // autoFocus is polyfilled/normalized by AutoFocusUtils
39
+ // autoFocus: HAS_BOOLEAN_VALUE,
40
+ autoPlay: HAS_BOOLEAN_VALUE,
41
+ capture: HAS_BOOLEAN_VALUE,
42
+ cellPadding: 0,
43
+ cellSpacing: 0,
44
+ charSet: 0,
45
+ challenge: 0,
46
+ checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
47
+ cite: 0,
48
+ classID: 0,
49
+ className: 0,
50
+ cols: HAS_POSITIVE_NUMERIC_VALUE,
51
+ colSpan: 0,
52
+ content: 0,
53
+ contentEditable: 0,
54
+ contextMenu: 0,
55
+ controls: HAS_BOOLEAN_VALUE,
56
+ coords: 0,
57
+ crossOrigin: 0,
58
+ data: 0, // For `<object />` acts as `src`.
59
+ dateTime: 0,
60
+ 'default': HAS_BOOLEAN_VALUE,
61
+ defer: HAS_BOOLEAN_VALUE,
62
+ dir: 0,
63
+ disabled: HAS_BOOLEAN_VALUE,
64
+ download: HAS_OVERLOADED_BOOLEAN_VALUE,
65
+ draggable: 0,
66
+ encType: 0,
67
+ form: 0,
68
+ formAction: 0,
69
+ formEncType: 0,
70
+ formMethod: 0,
71
+ formNoValidate: HAS_BOOLEAN_VALUE,
72
+ formTarget: 0,
73
+ frameBorder: 0,
74
+ headers: 0,
75
+ height: 0,
76
+ hidden: HAS_BOOLEAN_VALUE,
77
+ high: 0,
78
+ href: 0,
79
+ hrefLang: 0,
80
+ htmlFor: 0,
81
+ httpEquiv: 0,
82
+ icon: 0,
83
+ id: 0,
84
+ inputMode: 0,
85
+ integrity: 0,
86
+ is: 0,
87
+ keyParams: 0,
88
+ keyType: 0,
89
+ kind: 0,
90
+ label: 0,
91
+ lang: 0,
92
+ list: 0,
93
+ loop: HAS_BOOLEAN_VALUE,
94
+ low: 0,
95
+ manifest: 0,
96
+ marginHeight: 0,
97
+ marginWidth: 0,
98
+ max: 0,
99
+ maxLength: 0,
100
+ media: 0,
101
+ mediaGroup: 0,
102
+ method: 0,
103
+ min: 0,
104
+ minLength: 0,
105
+ // Caution; `option.selected` is not updated if `select.multiple` is
106
+ // disabled with `removeAttribute`.
107
+ multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
108
+ muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
109
+ name: 0,
110
+ nonce: 0,
111
+ noValidate: HAS_BOOLEAN_VALUE,
112
+ open: HAS_BOOLEAN_VALUE,
113
+ optimum: 0,
114
+ pattern: 0,
115
+ placeholder: 0,
116
+ playsInline: HAS_BOOLEAN_VALUE,
117
+ poster: 0,
118
+ preload: 0,
119
+ profile: 0,
120
+ radioGroup: 0,
121
+ readOnly: HAS_BOOLEAN_VALUE,
122
+ referrerPolicy: 0,
123
+ rel: 0,
124
+ required: HAS_BOOLEAN_VALUE,
125
+ reversed: HAS_BOOLEAN_VALUE,
126
+ role: 0,
127
+ rows: HAS_POSITIVE_NUMERIC_VALUE,
128
+ rowSpan: HAS_NUMERIC_VALUE,
129
+ sandbox: 0,
130
+ scope: 0,
131
+ scoped: HAS_BOOLEAN_VALUE,
132
+ scrolling: 0,
133
+ seamless: HAS_BOOLEAN_VALUE,
134
+ selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
135
+ shape: 0,
136
+ size: HAS_POSITIVE_NUMERIC_VALUE,
137
+ sizes: 0,
138
+ span: HAS_POSITIVE_NUMERIC_VALUE,
139
+ spellCheck: 0,
140
+ src: 0,
141
+ srcDoc: 0,
142
+ srcLang: 0,
143
+ srcSet: 0,
144
+ start: HAS_NUMERIC_VALUE,
145
+ step: 0,
146
+ style: 0,
147
+ summary: 0,
148
+ tabIndex: 0,
149
+ target: 0,
150
+ title: 0,
151
+ // Setting .type throws on non-<input> tags
152
+ type: 0,
153
+ useMap: 0,
154
+ value: 0,
155
+ width: 0,
156
+ wmode: 0,
157
+ wrap: 0,
158
+
159
+ /**
160
+ * RDFa Properties
161
+ */
162
+ about: 0,
163
+ datatype: 0,
164
+ inlist: 0,
165
+ prefix: 0,
166
+ // property is also supported for OpenGraph in meta tags.
167
+ property: 0,
168
+ resource: 0,
169
+ 'typeof': 0,
170
+ vocab: 0,
171
+
172
+ /**
173
+ * Non-standard Properties
174
+ */
175
+ // autoCapitalize and autoCorrect are supported in Mobile Safari for
176
+ // keyboard hints.
177
+ autoCapitalize: 0,
178
+ autoCorrect: 0,
179
+ // autoSave allows WebKit/Blink to persist values of input fields on page reloads
180
+ autoSave: 0,
181
+ // color is for Safari mask-icon link
182
+ color: 0,
183
+ // itemProp, itemScope, itemType are for
184
+ // Microdata support. See http://schema.org/docs/gs.html
185
+ itemProp: 0,
186
+ itemScope: HAS_BOOLEAN_VALUE,
187
+ itemType: 0,
188
+ // itemID and itemRef are for Microdata support as well but
189
+ // only specified in the WHATWG spec document. See
190
+ // https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api
191
+ itemID: 0,
192
+ itemRef: 0,
193
+ // results show looking glass icon and recent searches on input
194
+ // search fields in WebKit/Blink
195
+ results: 0,
196
+ // IE-only attribute that specifies security restrictions on an iframe
197
+ // as an alternative to the sandbox attribute on IE<10
198
+ security: 0,
199
+ // IE-only attribute that controls focus behavior
200
+ unselectable: 0
201
+ },
202
+ DOMAttributeNames: {
203
+ acceptCharset: 'accept-charset',
204
+ className: 'class',
205
+ htmlFor: 'for',
206
+ httpEquiv: 'http-equiv'
207
+ },
208
+ DOMPropertyNames: {},
209
+ DOMMutationMethods: {
210
+ value: function (node, value) {
211
+ if (value == null) {
212
+ return node.removeAttribute('value');
213
+ }
214
+
215
+ // Number inputs get special treatment due to some edge cases in
216
+ // Chrome. Let everything else assign the value attribute as normal.
217
+ // https://github.com/facebook/react/issues/7253#issuecomment-236074326
218
+ if (node.type !== 'number' || node.hasAttribute('value') === false) {
219
+ node.setAttribute('value', '' + value);
220
+ } else if (node.validity && !node.validity.badInput && node.ownerDocument.activeElement !== node) {
221
+ // Don't assign an attribute if validation reports bad
222
+ // input. Chrome will clear the value. Additionally, don't
223
+ // operate on inputs that have focus, otherwise Chrome might
224
+ // strip off trailing decimal places and cause the user's
225
+ // cursor position to jump to the beginning of the input.
226
+ //
227
+ // In ReactDOMInput, we have an onBlur event that will trigger
228
+ // this function again when focus is lost.
229
+ node.setAttribute('value', '' + value);
230
+ }
231
+ }
232
+ }
233
+ };
234
+
235
+ module.exports = HTMLDOMPropertyConfig;