react 15.3.2 → 15.4.0-rc.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 (210) hide show
  1. package/dist/react-with-addons.js +3864 -21390
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2639 -19486
  4. package/dist/react.min.js +2 -6
  5. package/lib/KeyEscapeUtils.js +0 -1
  6. package/lib/LinkedStateMixin.js +1 -3
  7. package/lib/PooledClass.js +3 -1
  8. package/lib/React.js +0 -1
  9. package/lib/ReactAddonsDOMDependencies.js +35 -0
  10. package/lib/ReactAddonsDOMDependenciesUMDShim.js +31 -0
  11. package/lib/ReactCSSTransitionGroup.js +60 -43
  12. package/lib/ReactCSSTransitionGroupChild.js +2 -3
  13. package/lib/ReactChildren.js +0 -1
  14. package/lib/ReactClass.js +38 -54
  15. package/lib/ReactComponent.js +0 -1
  16. package/lib/ReactComponentTreeDevtool.js +0 -1
  17. package/lib/ReactComponentTreeHook.js +84 -101
  18. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +4 -7
  19. package/lib/ReactComponentWithPureRenderMixin.js +0 -1
  20. package/lib/ReactCurrentOwner.js +1 -2
  21. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +5 -4
  22. package/lib/ReactDOMFactories.js +0 -1
  23. package/lib/ReactElement.js +6 -14
  24. package/lib/ReactElementSymbol.js +19 -0
  25. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +3 -9
  26. package/lib/ReactElementValidator.js +1 -3
  27. package/lib/ReactFragment.js +0 -1
  28. package/lib/ReactLink.js +0 -1
  29. package/lib/ReactNoopUpdateQueue.js +0 -1
  30. package/lib/ReactPropTypeLocationNames.js +1 -1
  31. package/lib/ReactPropTypeLocations.js +2 -12
  32. package/lib/ReactPropTypes.js +5 -3
  33. package/lib/ReactPropTypesSecret.js +1 -1
  34. package/lib/ReactPureComponent.js +0 -1
  35. package/lib/ReactStateSetters.js +0 -1
  36. package/lib/ReactTransitionChildMapping.js +0 -1
  37. package/lib/ReactTransitionEvents.js +1 -2
  38. package/lib/ReactTransitionGroup.js +145 -142
  39. package/lib/ReactUMDEntry.js +11 -6
  40. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +3 -6
  41. package/lib/ReactVersion.js +1 -2
  42. package/lib/ReactWithAddons.js +15 -3
  43. package/lib/ReactWithAddonsUMDEntry.js +11 -6
  44. package/lib/canDefineProperty.js +2 -1
  45. package/lib/checkReactTypeSpec.js +0 -1
  46. package/lib/deprecated.js +0 -1
  47. package/lib/flattenChildren.js +0 -1
  48. package/lib/getIteratorFn.js +0 -1
  49. package/lib/onlyChild.js +0 -1
  50. package/lib/reactProdInvariant.js +0 -1
  51. package/lib/shallowCompare.js +1 -2
  52. package/lib/sliceChildren.js +0 -1
  53. package/lib/traverseAllChildren.js +11 -3
  54. package/lib/update.js +6 -8
  55. package/package.json +1 -1
  56. package/lib/AutoFocusUtils.js +0 -24
  57. package/lib/BeforeInputEventPlugin.js +0 -390
  58. package/lib/CSSProperty.js +0 -148
  59. package/lib/CSSPropertyOperations.js +0 -205
  60. package/lib/CallbackQueue.js +0 -106
  61. package/lib/ChangeEventPlugin.js +0 -325
  62. package/lib/DOMChildrenOperations.js +0 -194
  63. package/lib/DOMLazyTree.js +0 -118
  64. package/lib/DOMProperty.js +0 -206
  65. package/lib/DOMPropertyOperations.js +0 -221
  66. package/lib/Danger.js +0 -48
  67. package/lib/DefaultEventPluginOrder.js +0 -27
  68. package/lib/DisabledInputUtils.js +0 -50
  69. package/lib/EnterLeaveEventPlugin.js +0 -105
  70. package/lib/EventConstants.js +0 -97
  71. package/lib/EventPluginHub.js +0 -251
  72. package/lib/EventPluginRegistry.js +0 -247
  73. package/lib/EventPluginUtils.js +0 -229
  74. package/lib/EventPropagators.js +0 -137
  75. package/lib/FallbackCompositionState.js +0 -95
  76. package/lib/HTMLDOMPropertyConfig.js +0 -212
  77. package/lib/LinkedValueUtils.js +0 -136
  78. package/lib/NativeMethodsMixin.js +0 -167
  79. package/lib/ReactBrowserEventEmitter.js +0 -330
  80. package/lib/ReactChildReconciler.js +0 -154
  81. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  82. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  83. package/lib/ReactComponentEnvironment.js +0 -45
  84. package/lib/ReactComponentTreeTestUtils.js +0 -87
  85. package/lib/ReactCompositeComponent.js +0 -904
  86. package/lib/ReactDOM.js +0 -110
  87. package/lib/ReactDOMButton.js +0 -24
  88. package/lib/ReactDOMComponent.js +0 -1006
  89. package/lib/ReactDOMComponentTree.js +0 -188
  90. package/lib/ReactDOMContainerInfo.js +0 -33
  91. package/lib/ReactDOMEmptyComponent.js +0 -60
  92. package/lib/ReactDOMFiber.js +0 -76
  93. package/lib/ReactDOMIDOperations.js +0 -34
  94. package/lib/ReactDOMInput.js +0 -269
  95. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  96. package/lib/ReactDOMOption.js +0 -123
  97. package/lib/ReactDOMSelect.js +0 -201
  98. package/lib/ReactDOMSelection.js +0 -212
  99. package/lib/ReactDOMServer.js +0 -26
  100. package/lib/ReactDOMTextComponent.js +0 -164
  101. package/lib/ReactDOMTextarea.js +0 -155
  102. package/lib/ReactDOMTreeTraversal.js +0 -136
  103. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  104. package/lib/ReactDebugTool.js +0 -301
  105. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  106. package/lib/ReactDefaultInjection.js +0 -84
  107. package/lib/ReactEmptyComponent.js +0 -30
  108. package/lib/ReactErrorUtils.js +0 -76
  109. package/lib/ReactEventEmitterMixin.js +0 -33
  110. package/lib/ReactEventListener.js +0 -157
  111. package/lib/ReactFeatureFlags.js +0 -22
  112. package/lib/ReactHostComponent.js +0 -76
  113. package/lib/ReactHostOperationHistoryHook.js +0 -37
  114. package/lib/ReactInjection.js +0 -36
  115. package/lib/ReactInputSelection.js +0 -124
  116. package/lib/ReactInstanceHandles.js +0 -302
  117. package/lib/ReactInstanceMap.js +0 -48
  118. package/lib/ReactInstrumentation.js +0 -21
  119. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  120. package/lib/ReactMarkupChecksum.js +0 -50
  121. package/lib/ReactMount.js +0 -534
  122. package/lib/ReactMultiChild.js +0 -451
  123. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  124. package/lib/ReactNative.js +0 -71
  125. package/lib/ReactNativeAttributePayload.js +0 -371
  126. package/lib/ReactNativeBaseComponent.js +0 -198
  127. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  128. package/lib/ReactNativeComponentEnvironment.js +0 -31
  129. package/lib/ReactNativeComponentTree.js +0 -68
  130. package/lib/ReactNativeContainerInfo.js +0 -21
  131. package/lib/ReactNativeDOMIDOperations.js +0 -79
  132. package/lib/ReactNativeDefaultInjection.js +0 -101
  133. package/lib/ReactNativeEventEmitter.js +0 -191
  134. package/lib/ReactNativeEventPluginOrder.js +0 -16
  135. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  136. package/lib/ReactNativeMount.js +0 -193
  137. package/lib/ReactNativePropRegistry.js +0 -52
  138. package/lib/ReactNativeReconcileTransaction.js +0 -129
  139. package/lib/ReactNativeTagHandles.js +0 -56
  140. package/lib/ReactNativeTextComponent.js +0 -71
  141. package/lib/ReactNativeTreeTraversal.js +0 -127
  142. package/lib/ReactNodeTypes.js +0 -40
  143. package/lib/ReactNoop.js +0 -173
  144. package/lib/ReactOwner.js +0 -94
  145. package/lib/ReactPerf.js +0 -494
  146. package/lib/ReactReconcileTransaction.js +0 -178
  147. package/lib/ReactReconciler.js +0 -168
  148. package/lib/ReactRef.js +0 -80
  149. package/lib/ReactServerBatchingStrategy.js +0 -22
  150. package/lib/ReactServerRendering.js +0 -90
  151. package/lib/ReactServerRenderingTransaction.js +0 -90
  152. package/lib/ReactServerUpdateQueue.js +0 -141
  153. package/lib/ReactSimpleEmptyComponent.js +0 -37
  154. package/lib/ReactTestMount.js +0 -126
  155. package/lib/ReactTestReconcileTransaction.js +0 -121
  156. package/lib/ReactTestRenderer.js +0 -144
  157. package/lib/ReactTestUtils.js +0 -518
  158. package/lib/ReactUpdateQueue.js +0 -226
  159. package/lib/ReactUpdates.js +0 -251
  160. package/lib/ResponderEventPlugin.js +0 -510
  161. package/lib/ResponderSyntheticEvent.js +0 -39
  162. package/lib/ResponderTouchHistoryStore.js +0 -184
  163. package/lib/SVGDOMPropertyConfig.js +0 -302
  164. package/lib/SelectEventPlugin.js +0 -196
  165. package/lib/SimpleEventPlugin.js +0 -635
  166. package/lib/SyntheticAnimationEvent.js +0 -39
  167. package/lib/SyntheticClipboardEvent.js +0 -38
  168. package/lib/SyntheticCompositionEvent.js +0 -36
  169. package/lib/SyntheticDragEvent.js +0 -36
  170. package/lib/SyntheticEvent.js +0 -268
  171. package/lib/SyntheticFocusEvent.js +0 -36
  172. package/lib/SyntheticInputEvent.js +0 -37
  173. package/lib/SyntheticKeyboardEvent.js +0 -84
  174. package/lib/SyntheticMouseEvent.js +0 -72
  175. package/lib/SyntheticTouchEvent.js +0 -45
  176. package/lib/SyntheticTransitionEvent.js +0 -39
  177. package/lib/SyntheticUIEvent.js +0 -59
  178. package/lib/SyntheticWheelEvent.js +0 -54
  179. package/lib/TapEventPlugin.js +0 -110
  180. package/lib/TouchHistoryMath.js +0 -99
  181. package/lib/Transaction.js +0 -233
  182. package/lib/ViewportMetrics.js +0 -27
  183. package/lib/accumulate.js +0 -46
  184. package/lib/accumulateInto.js +0 -58
  185. package/lib/adler32.js +0 -44
  186. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  187. package/lib/createReactNativeComponentClass.js +0 -42
  188. package/lib/dangerousStyleValue.js +0 -79
  189. package/lib/escapeTextContentForBrowser.js +0 -123
  190. package/lib/findDOMNode.js +0 -60
  191. package/lib/findNodeHandle.js +0 -91
  192. package/lib/forEachAccumulated.js +0 -31
  193. package/lib/getEventCharCode.js +0 -50
  194. package/lib/getEventKey.js +0 -102
  195. package/lib/getEventModifierState.js +0 -43
  196. package/lib/getEventTarget.js +0 -35
  197. package/lib/getHostComponentFromComposite.js +0 -30
  198. package/lib/getNodeForCharacterOffset.js +0 -74
  199. package/lib/getTestDocument.js +0 -21
  200. package/lib/getTextContentAccessor.js +0 -33
  201. package/lib/getVendorPrefixedEventName.js +0 -101
  202. package/lib/instantiateReactComponent.js +0 -119
  203. package/lib/isEventSupported.js +0 -60
  204. package/lib/isTextInputElement.js +0 -51
  205. package/lib/quoteAttributeValueForBrowser.js +0 -26
  206. package/lib/reactComponentExpect.js +0 -217
  207. package/lib/setInnerHTML.js +0 -98
  208. package/lib/setTextContent.js +0 -48
  209. package/lib/shouldUpdateReactComponent.js +0 -42
  210. package/lib/validateDOMNesting.js +0 -382
@@ -1,226 +0,0 @@
1
- /**
2
- * Copyright 2015-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
- * @providesModule ReactUpdateQueue
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant');
15
-
16
- var ReactCurrentOwner = require('./ReactCurrentOwner');
17
- var ReactInstanceMap = require('./ReactInstanceMap');
18
- var ReactInstrumentation = require('./ReactInstrumentation');
19
- var ReactUpdates = require('./ReactUpdates');
20
-
21
- var invariant = require('fbjs/lib/invariant');
22
- var warning = require('fbjs/lib/warning');
23
-
24
- function enqueueUpdate(internalInstance) {
25
- ReactUpdates.enqueueUpdate(internalInstance);
26
- }
27
-
28
- function formatUnexpectedArgument(arg) {
29
- var type = typeof arg;
30
- if (type !== 'object') {
31
- return type;
32
- }
33
- var displayName = arg.constructor && arg.constructor.name || type;
34
- var keys = Object.keys(arg);
35
- if (keys.length > 0 && keys.length < 20) {
36
- return displayName + ' (keys: ' + keys.join(', ') + ')';
37
- }
38
- return displayName;
39
- }
40
-
41
- function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
42
- var internalInstance = ReactInstanceMap.get(publicInstance);
43
- if (!internalInstance) {
44
- if (process.env.NODE_ENV !== 'production') {
45
- var ctor = publicInstance.constructor;
46
- // Only warn when we have a callerName. Otherwise we should be silent.
47
- // We're probably calling from enqueueCallback. We don't want to warn
48
- // there because we already warned for the corresponding lifecycle method.
49
- process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, ctor && (ctor.displayName || ctor.name) || 'ReactClass') : void 0;
50
- }
51
- return null;
52
- }
53
-
54
- if (process.env.NODE_ENV !== 'production') {
55
- process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition (such as ' + 'within `render` or another component\'s constructor). Render methods ' + 'should be a pure function of props and state; constructor ' + 'side-effects are an anti-pattern, but can be moved to ' + '`componentWillMount`.', callerName) : void 0;
56
- }
57
-
58
- return internalInstance;
59
- }
60
-
61
- /**
62
- * ReactUpdateQueue allows for state updates to be scheduled into a later
63
- * reconciliation step.
64
- */
65
- var ReactUpdateQueue = {
66
-
67
- /**
68
- * Checks whether or not this composite component is mounted.
69
- * @param {ReactClass} publicInstance The instance we want to test.
70
- * @return {boolean} True if mounted, false otherwise.
71
- * @protected
72
- * @final
73
- */
74
- isMounted: function (publicInstance) {
75
- if (process.env.NODE_ENV !== 'production') {
76
- var owner = ReactCurrentOwner.current;
77
- if (owner !== null) {
78
- process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : void 0;
79
- owner._warnedAboutRefsInRender = true;
80
- }
81
- }
82
- var internalInstance = ReactInstanceMap.get(publicInstance);
83
- if (internalInstance) {
84
- // During componentWillMount and render this will still be null but after
85
- // that will always render to something. At least for now. So we can use
86
- // this hack.
87
- return !!internalInstance._renderedComponent;
88
- } else {
89
- return false;
90
- }
91
- },
92
-
93
- /**
94
- * Enqueue a callback that will be executed after all the pending updates
95
- * have processed.
96
- *
97
- * @param {ReactClass} publicInstance The instance to use as `this` context.
98
- * @param {?function} callback Called after state is updated.
99
- * @param {string} callerName Name of the calling function in the public API.
100
- * @internal
101
- */
102
- enqueueCallback: function (publicInstance, callback, callerName) {
103
- ReactUpdateQueue.validateCallback(callback, callerName);
104
- var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
105
-
106
- // Previously we would throw an error if we didn't have an internal
107
- // instance. Since we want to make it a no-op instead, we mirror the same
108
- // behavior we have in other enqueue* methods.
109
- // We also need to ignore callbacks in componentWillMount. See
110
- // enqueueUpdates.
111
- if (!internalInstance) {
112
- return null;
113
- }
114
-
115
- if (internalInstance._pendingCallbacks) {
116
- internalInstance._pendingCallbacks.push(callback);
117
- } else {
118
- internalInstance._pendingCallbacks = [callback];
119
- }
120
- // TODO: The callback here is ignored when setState is called from
121
- // componentWillMount. Either fix it or disallow doing so completely in
122
- // favor of getInitialState. Alternatively, we can disallow
123
- // componentWillMount during server-side rendering.
124
- enqueueUpdate(internalInstance);
125
- },
126
-
127
- enqueueCallbackInternal: function (internalInstance, callback) {
128
- if (internalInstance._pendingCallbacks) {
129
- internalInstance._pendingCallbacks.push(callback);
130
- } else {
131
- internalInstance._pendingCallbacks = [callback];
132
- }
133
- enqueueUpdate(internalInstance);
134
- },
135
-
136
- /**
137
- * Forces an update. This should only be invoked when it is known with
138
- * certainty that we are **not** in a DOM transaction.
139
- *
140
- * You may want to call this when you know that some deeper aspect of the
141
- * component's state has changed but `setState` was not called.
142
- *
143
- * This will not invoke `shouldComponentUpdate`, but it will invoke
144
- * `componentWillUpdate` and `componentDidUpdate`.
145
- *
146
- * @param {ReactClass} publicInstance The instance that should rerender.
147
- * @internal
148
- */
149
- enqueueForceUpdate: function (publicInstance) {
150
- var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'forceUpdate');
151
-
152
- if (!internalInstance) {
153
- return;
154
- }
155
-
156
- internalInstance._pendingForceUpdate = true;
157
-
158
- enqueueUpdate(internalInstance);
159
- },
160
-
161
- /**
162
- * Replaces all of the state. Always use this or `setState` to mutate state.
163
- * You should treat `this.state` as immutable.
164
- *
165
- * There is no guarantee that `this.state` will be immediately updated, so
166
- * accessing `this.state` after calling this method may return the old value.
167
- *
168
- * @param {ReactClass} publicInstance The instance that should rerender.
169
- * @param {object} completeState Next state.
170
- * @internal
171
- */
172
- enqueueReplaceState: function (publicInstance, completeState) {
173
- var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState');
174
-
175
- if (!internalInstance) {
176
- return;
177
- }
178
-
179
- internalInstance._pendingStateQueue = [completeState];
180
- internalInstance._pendingReplaceState = true;
181
-
182
- enqueueUpdate(internalInstance);
183
- },
184
-
185
- /**
186
- * Sets a subset of the state. This only exists because _pendingState is
187
- * internal. This provides a merging strategy that is not available to deep
188
- * properties which is confusing. TODO: Expose pendingState or don't use it
189
- * during the merge.
190
- *
191
- * @param {ReactClass} publicInstance The instance that should rerender.
192
- * @param {object} partialState Next partial state to be merged with state.
193
- * @internal
194
- */
195
- enqueueSetState: function (publicInstance, partialState) {
196
- if (process.env.NODE_ENV !== 'production') {
197
- ReactInstrumentation.debugTool.onSetState();
198
- process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : void 0;
199
- }
200
-
201
- var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setState');
202
-
203
- if (!internalInstance) {
204
- return;
205
- }
206
-
207
- var queue = internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = []);
208
- queue.push(partialState);
209
-
210
- enqueueUpdate(internalInstance);
211
- },
212
-
213
- enqueueElementInternal: function (internalInstance, nextElement, nextContext) {
214
- internalInstance._pendingElement = nextElement;
215
- // TODO: introduce _pendingContext instead of setting it directly.
216
- internalInstance._context = nextContext;
217
- enqueueUpdate(internalInstance);
218
- },
219
-
220
- validateCallback: function (callback, callerName) {
221
- !(!callback || typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.', callerName, formatUnexpectedArgument(callback)) : _prodInvariant('122', callerName, formatUnexpectedArgument(callback)) : void 0;
222
- }
223
-
224
- };
225
-
226
- module.exports = ReactUpdateQueue;
@@ -1,251 +0,0 @@
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
- * @providesModule ReactUpdates
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant'),
15
- _assign = require('object-assign');
16
-
17
- var CallbackQueue = require('./CallbackQueue');
18
- var PooledClass = require('./PooledClass');
19
- var ReactFeatureFlags = require('./ReactFeatureFlags');
20
- var ReactReconciler = require('./ReactReconciler');
21
- var Transaction = require('./Transaction');
22
-
23
- var invariant = require('fbjs/lib/invariant');
24
-
25
- var dirtyComponents = [];
26
- var updateBatchNumber = 0;
27
- var asapCallbackQueue = CallbackQueue.getPooled();
28
- var asapEnqueued = false;
29
-
30
- var batchingStrategy = null;
31
-
32
- function ensureInjected() {
33
- !(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must inject a reconcile transaction class and batching strategy') : _prodInvariant('123') : void 0;
34
- }
35
-
36
- var NESTED_UPDATES = {
37
- initialize: function () {
38
- this.dirtyComponentsLength = dirtyComponents.length;
39
- },
40
- close: function () {
41
- if (this.dirtyComponentsLength !== dirtyComponents.length) {
42
- // Additional updates were enqueued by componentDidUpdate handlers or
43
- // similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
44
- // these new updates so that if A's componentDidUpdate calls setState on
45
- // B, B will update before the callback A's updater provided when calling
46
- // setState.
47
- dirtyComponents.splice(0, this.dirtyComponentsLength);
48
- flushBatchedUpdates();
49
- } else {
50
- dirtyComponents.length = 0;
51
- }
52
- }
53
- };
54
-
55
- var UPDATE_QUEUEING = {
56
- initialize: function () {
57
- this.callbackQueue.reset();
58
- },
59
- close: function () {
60
- this.callbackQueue.notifyAll();
61
- }
62
- };
63
-
64
- var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
65
-
66
- function ReactUpdatesFlushTransaction() {
67
- this.reinitializeTransaction();
68
- this.dirtyComponentsLength = null;
69
- this.callbackQueue = CallbackQueue.getPooled();
70
- this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled(
71
- /* useCreateElement */true);
72
- }
73
-
74
- _assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
75
- getTransactionWrappers: function () {
76
- return TRANSACTION_WRAPPERS;
77
- },
78
-
79
- destructor: function () {
80
- this.dirtyComponentsLength = null;
81
- CallbackQueue.release(this.callbackQueue);
82
- this.callbackQueue = null;
83
- ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
84
- this.reconcileTransaction = null;
85
- },
86
-
87
- perform: function (method, scope, a) {
88
- // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
89
- // with this transaction's wrappers around it.
90
- return Transaction.Mixin.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a);
91
- }
92
- });
93
-
94
- PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
95
-
96
- function batchedUpdates(callback, a, b, c, d, e) {
97
- ensureInjected();
98
- batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
99
- }
100
-
101
- /**
102
- * Array comparator for ReactComponents by mount ordering.
103
- *
104
- * @param {ReactComponent} c1 first component you're comparing
105
- * @param {ReactComponent} c2 second component you're comparing
106
- * @return {number} Return value usable by Array.prototype.sort().
107
- */
108
- function mountOrderComparator(c1, c2) {
109
- return c1._mountOrder - c2._mountOrder;
110
- }
111
-
112
- function runBatchedUpdates(transaction) {
113
- var len = transaction.dirtyComponentsLength;
114
- !(len === dirtyComponents.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected flush transaction\'s stored dirty-components length (%s) to match dirty-components array length (%s).', len, dirtyComponents.length) : _prodInvariant('124', len, dirtyComponents.length) : void 0;
115
-
116
- // Since reconciling a component higher in the owner hierarchy usually (not
117
- // always -- see shouldComponentUpdate()) will reconcile children, reconcile
118
- // them before their children by sorting the array.
119
- dirtyComponents.sort(mountOrderComparator);
120
-
121
- // Any updates enqueued while reconciling must be performed after this entire
122
- // batch. Otherwise, if dirtyComponents is [A, B] where A has children B and
123
- // C, B could update twice in a single batch if C's render enqueues an update
124
- // to B (since B would have already updated, we should skip it, and the only
125
- // way we can know to do so is by checking the batch counter).
126
- updateBatchNumber++;
127
-
128
- for (var i = 0; i < len; i++) {
129
- // If a component is unmounted before pending changes apply, it will still
130
- // be here, but we assume that it has cleared its _pendingCallbacks and
131
- // that performUpdateIfNecessary is a noop.
132
- var component = dirtyComponents[i];
133
-
134
- // If performUpdateIfNecessary happens to enqueue any new updates, we
135
- // shouldn't execute the callbacks until the next render happens, so
136
- // stash the callbacks first
137
- var callbacks = component._pendingCallbacks;
138
- component._pendingCallbacks = null;
139
-
140
- var markerName;
141
- if (ReactFeatureFlags.logTopLevelRenders) {
142
- var namedComponent = component;
143
- // Duck type TopLevelWrapper. This is probably always true.
144
- if (component._currentElement.props === component._renderedComponent._currentElement) {
145
- namedComponent = component._renderedComponent;
146
- }
147
- markerName = 'React update: ' + namedComponent.getName();
148
- console.time(markerName);
149
- }
150
-
151
- ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction, updateBatchNumber);
152
-
153
- if (markerName) {
154
- console.timeEnd(markerName);
155
- }
156
-
157
- if (callbacks) {
158
- for (var j = 0; j < callbacks.length; j++) {
159
- transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance());
160
- }
161
- }
162
- }
163
- }
164
-
165
- var flushBatchedUpdates = function () {
166
- // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
167
- // array and perform any updates enqueued by mount-ready handlers (i.e.,
168
- // componentDidUpdate) but we need to check here too in order to catch
169
- // updates enqueued by setState callbacks and asap calls.
170
- while (dirtyComponents.length || asapEnqueued) {
171
- if (dirtyComponents.length) {
172
- var transaction = ReactUpdatesFlushTransaction.getPooled();
173
- transaction.perform(runBatchedUpdates, null, transaction);
174
- ReactUpdatesFlushTransaction.release(transaction);
175
- }
176
-
177
- if (asapEnqueued) {
178
- asapEnqueued = false;
179
- var queue = asapCallbackQueue;
180
- asapCallbackQueue = CallbackQueue.getPooled();
181
- queue.notifyAll();
182
- CallbackQueue.release(queue);
183
- }
184
- }
185
- };
186
-
187
- /**
188
- * Mark a component as needing a rerender, adding an optional callback to a
189
- * list of functions which will be executed once the rerender occurs.
190
- */
191
- function enqueueUpdate(component) {
192
- ensureInjected();
193
-
194
- // Various parts of our code (such as ReactCompositeComponent's
195
- // _renderValidatedComponent) assume that calls to render aren't nested;
196
- // verify that that's the case. (This is called by each top-level update
197
- // function, like setState, forceUpdate, etc.; creation and
198
- // destruction of top-level components is guarded in ReactMount.)
199
-
200
- if (!batchingStrategy.isBatchingUpdates) {
201
- batchingStrategy.batchedUpdates(enqueueUpdate, component);
202
- return;
203
- }
204
-
205
- dirtyComponents.push(component);
206
- if (component._updateBatchNumber == null) {
207
- component._updateBatchNumber = updateBatchNumber + 1;
208
- }
209
- }
210
-
211
- /**
212
- * Enqueue a callback to be run at the end of the current batching cycle. Throws
213
- * if no updates are currently being performed.
214
- */
215
- function asap(callback, context) {
216
- !batchingStrategy.isBatchingUpdates ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context whereupdates are not being batched.') : _prodInvariant('125') : void 0;
217
- asapCallbackQueue.enqueue(callback, context);
218
- asapEnqueued = true;
219
- }
220
-
221
- var ReactUpdatesInjection = {
222
- injectReconcileTransaction: function (ReconcileTransaction) {
223
- !ReconcileTransaction ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a reconcile transaction class') : _prodInvariant('126') : void 0;
224
- ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
225
- },
226
-
227
- injectBatchingStrategy: function (_batchingStrategy) {
228
- !_batchingStrategy ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batching strategy') : _prodInvariant('127') : void 0;
229
- !(typeof _batchingStrategy.batchedUpdates === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batchedUpdates() function') : _prodInvariant('128') : void 0;
230
- !(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide an isBatchingUpdates boolean attribute') : _prodInvariant('129') : void 0;
231
- batchingStrategy = _batchingStrategy;
232
- }
233
- };
234
-
235
- var ReactUpdates = {
236
- /**
237
- * React references `ReactReconcileTransaction` using this property in order
238
- * to allow dependency injection.
239
- *
240
- * @internal
241
- */
242
- ReactReconcileTransaction: null,
243
-
244
- batchedUpdates: batchedUpdates,
245
- enqueueUpdate: enqueueUpdate,
246
- flushBatchedUpdates: flushBatchedUpdates,
247
- injection: ReactUpdatesInjection,
248
- asap: asap
249
- };
250
-
251
- module.exports = ReactUpdates;