react 0.12.2 → 0.13.0-beta.2

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 (184) hide show
  1. package/dist/JSXTransformer.js +986 -511
  2. package/dist/react-with-addons.js +6076 -4560
  3. package/dist/react-with-addons.min.js +6 -7
  4. package/dist/react.js +5386 -4170
  5. package/dist/react.min.js +6 -7
  6. package/lib/AutoFocusMixin.js +2 -2
  7. package/lib/BeforeInputEventPlugin.js +388 -115
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +2 -2
  10. package/lib/CSSPropertyOperations.js +58 -11
  11. package/lib/CallbackQueue.js +3 -3
  12. package/lib/ChangeEventPlugin.js +4 -4
  13. package/lib/ClientReactRootIndex.js +2 -2
  14. package/lib/DOMChildrenOperations.js +10 -47
  15. package/lib/DOMProperty.js +2 -2
  16. package/lib/DOMPropertyOperations.js +11 -16
  17. package/lib/Danger.js +8 -7
  18. package/lib/DefaultEventPluginOrder.js +3 -4
  19. package/lib/EnterLeaveEventPlugin.js +2 -2
  20. package/lib/EventConstants.js +2 -2
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +10 -8
  23. package/lib/EventPluginRegistry.js +2 -2
  24. package/lib/EventPluginUtils.js +4 -4
  25. package/lib/EventPropagators.js +2 -2
  26. package/lib/ExecutionEnvironment.js +3 -4
  27. package/lib/FallbackCompositionState.js +89 -0
  28. package/lib/HTMLDOMPropertyConfig.js +23 -10
  29. package/lib/LinkedStateMixin.js +2 -2
  30. package/lib/LinkedValueUtils.js +4 -4
  31. package/lib/LocalEventTrapMixin.js +10 -3
  32. package/lib/MobileSafariClickEventPlugin.js +2 -2
  33. package/lib/Object.assign.js +4 -2
  34. package/lib/PooledClass.js +2 -2
  35. package/lib/React.js +19 -58
  36. package/lib/ReactBrowserComponentMixin.js +4 -14
  37. package/lib/ReactBrowserEventEmitter.js +6 -8
  38. package/lib/ReactCSSTransitionGroup.js +5 -2
  39. package/lib/ReactCSSTransitionGroupChild.js +20 -7
  40. package/lib/ReactChildReconciler.js +125 -0
  41. package/lib/ReactChildren.js +13 -10
  42. package/lib/ReactClass.js +918 -0
  43. package/lib/ReactComponent.js +98 -406
  44. package/lib/ReactComponentBrowserEnvironment.js +11 -84
  45. package/lib/ReactComponentEnvironment.js +57 -0
  46. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  47. package/lib/ReactCompositeComponent.js +574 -1140
  48. package/lib/ReactContext.js +17 -3
  49. package/lib/ReactCurrentOwner.js +2 -2
  50. package/lib/ReactDOM.js +4 -9
  51. package/lib/ReactDOMButton.js +6 -7
  52. package/lib/ReactDOMComponent.js +123 -105
  53. package/lib/ReactDOMForm.js +6 -7
  54. package/lib/ReactDOMIDOperations.js +59 -77
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +5 -7
  57. package/lib/ReactDOMInput.js +6 -7
  58. package/lib/ReactDOMOption.js +6 -7
  59. package/lib/ReactDOMSelect.js +58 -66
  60. package/lib/ReactDOMSelection.js +7 -3
  61. package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
  62. package/lib/ReactDOMTextarea.js +6 -7
  63. package/lib/ReactDefaultBatchingStrategy.js +5 -5
  64. package/lib/ReactDefaultInjection.js +39 -9
  65. package/lib/ReactDefaultPerf.js +17 -8
  66. package/lib/ReactDefaultPerfAnalysis.js +2 -2
  67. package/lib/ReactElement.js +23 -15
  68. package/lib/ReactElementValidator.js +206 -89
  69. package/lib/ReactEmptyComponent.js +33 -15
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +2 -2
  72. package/lib/ReactEventListener.js +4 -5
  73. package/lib/ReactFragment.js +172 -0
  74. package/lib/ReactInjection.js +8 -6
  75. package/lib/ReactInputSelection.js +4 -5
  76. package/lib/ReactInstanceHandles.js +4 -3
  77. package/lib/ReactInstanceMap.js +47 -0
  78. package/lib/ReactLifeCycle.js +35 -0
  79. package/lib/ReactLink.js +2 -2
  80. package/lib/ReactMarkupChecksum.js +2 -2
  81. package/lib/ReactMount.js +264 -71
  82. package/lib/ReactMultiChild.js +50 -48
  83. package/lib/ReactMultiChildUpdateTypes.js +2 -2
  84. package/lib/ReactNativeComponent.js +59 -25
  85. package/lib/ReactOwner.js +5 -49
  86. package/lib/ReactPerf.js +22 -2
  87. package/lib/ReactPropTransferer.js +3 -58
  88. package/lib/ReactPropTypeLocationNames.js +2 -2
  89. package/lib/ReactPropTypeLocations.js +2 -2
  90. package/lib/ReactPropTypes.js +17 -25
  91. package/lib/ReactPutListenerQueue.js +2 -2
  92. package/lib/ReactReconcileTransaction.js +2 -2
  93. package/lib/ReactReconciler.js +121 -0
  94. package/lib/ReactRef.js +69 -0
  95. package/lib/ReactRootIndex.js +2 -2
  96. package/lib/ReactServerRendering.js +6 -4
  97. package/lib/ReactServerRenderingTransaction.js +2 -2
  98. package/lib/ReactStateSetters.js +2 -2
  99. package/lib/ReactTestUtils.js +113 -27
  100. package/lib/ReactTransitionChildMapping.js +8 -4
  101. package/lib/ReactTransitionEvents.js +2 -2
  102. package/lib/ReactTransitionGroup.js +53 -12
  103. package/lib/ReactUpdateQueue.js +295 -0
  104. package/lib/ReactUpdates.js +54 -62
  105. package/lib/ReactWithAddons.js +4 -2
  106. package/lib/SVGDOMPropertyConfig.js +2 -2
  107. package/lib/SelectEventPlugin.js +4 -4
  108. package/lib/ServerReactRootIndex.js +2 -2
  109. package/lib/SimpleEventPlugin.js +4 -4
  110. package/lib/SyntheticClipboardEvent.js +2 -3
  111. package/lib/SyntheticCompositionEvent.js +2 -3
  112. package/lib/SyntheticDragEvent.js +2 -2
  113. package/lib/SyntheticEvent.js +12 -4
  114. package/lib/SyntheticFocusEvent.js +2 -2
  115. package/lib/SyntheticInputEvent.js +2 -3
  116. package/lib/SyntheticKeyboardEvent.js +2 -2
  117. package/lib/SyntheticMouseEvent.js +3 -5
  118. package/lib/SyntheticTouchEvent.js +2 -2
  119. package/lib/SyntheticUIEvent.js +2 -2
  120. package/lib/SyntheticWheelEvent.js +2 -2
  121. package/lib/Transaction.js +4 -4
  122. package/lib/ViewportMetrics.js +3 -6
  123. package/lib/accumulateInto.js +2 -2
  124. package/lib/adler32.js +2 -2
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +4 -4
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +4 -4
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +1 -1
  133. package/lib/dangerousStyleValue.js +2 -2
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
  137. package/lib/findDOMNode.js +51 -0
  138. package/lib/flattenChildren.js +12 -23
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +2 -2
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +2 -2
  143. package/lib/getEventKey.js +2 -2
  144. package/lib/getEventModifierState.js +2 -2
  145. package/lib/getEventTarget.js +2 -2
  146. package/lib/getIteratorFn.js +42 -0
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +3 -3
  149. package/lib/getReactRootElementInContainer.js +2 -2
  150. package/lib/getTextContentAccessor.js +2 -2
  151. package/lib/getUnboundedScrollPosition.js +1 -1
  152. package/lib/hyphenate.js +1 -1
  153. package/lib/hyphenateStyleName.js +1 -1
  154. package/lib/instantiateReactComponent.js +90 -68
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +2 -2
  157. package/lib/isNode.js +4 -5
  158. package/lib/isTextInputElement.js +3 -4
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +2 -2
  161. package/lib/keyMirror.js +2 -2
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +5 -6
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/performance.js +1 -1
  167. package/lib/performanceNow.js +1 -1
  168. package/lib/quoteAttributeValueForBrowser.js +26 -0
  169. package/lib/setInnerHTML.js +13 -2
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +2 -2
  172. package/lib/shouldUpdateReactComponent.js +71 -7
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +114 -56
  175. package/lib/update.js +2 -2
  176. package/lib/warning.js +20 -2
  177. package/package.json +1 -1
  178. package/lib/CompositionEventPlugin.js +0 -257
  179. package/lib/ReactLegacyElement.js +0 -243
  180. package/lib/copyProperties.js +0 -54
  181. package/lib/deprecated.js +0 -47
  182. package/lib/merge.js +0 -34
  183. package/lib/mergeInto.js +0 -24
  184. package/lib/monitorCodeUse.js +0 -30
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Copyright 2015, 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 ReactLifeCycle = require("./ReactLifeCycle");
15
+ var ReactCurrentOwner = require("./ReactCurrentOwner");
16
+ var ReactElement = require("./ReactElement");
17
+ var ReactInstanceMap = require("./ReactInstanceMap");
18
+ var ReactUpdates = require("./ReactUpdates");
19
+
20
+ var assign = require("./Object.assign");
21
+ var invariant = require("./invariant");
22
+ var warning = require("./warning");
23
+
24
+ function enqueueUpdate(internalInstance) {
25
+ if (internalInstance !== ReactLifeCycle.currentlyMountingInstance) {
26
+ // If we're in a componentWillMount handler, don't enqueue a rerender
27
+ // because ReactUpdates assumes we're in a browser context (which is
28
+ // wrong for server rendering) and we're about to do a render anyway.
29
+ // See bug in #1740.
30
+ ReactUpdates.enqueueUpdate(internalInstance);
31
+ }
32
+ }
33
+
34
+ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
35
+ ("production" !== process.env.NODE_ENV ? invariant(
36
+ ReactCurrentOwner.current == null,
37
+ '%s(...): Cannot update during an existing state transition ' +
38
+ '(such as within `render`). Render methods should be a pure function ' +
39
+ 'of props and state.',
40
+ callerName
41
+ ) : invariant(ReactCurrentOwner.current == null));
42
+
43
+ var internalInstance = ReactInstanceMap.get(publicInstance);
44
+ if (!internalInstance) {
45
+ if ("production" !== process.env.NODE_ENV) {
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
+ ("production" !== process.env.NODE_ENV ? warning(
50
+ !callerName,
51
+ '%s(...): Can only update a mounted or mounting component. ' +
52
+ 'This usually means you called %s() on an unmounted ' +
53
+ 'component. This is a no-op.',
54
+ callerName,
55
+ callerName
56
+ ) : null);
57
+ }
58
+ return null;
59
+ }
60
+
61
+ if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
62
+ return null;
63
+ }
64
+
65
+ return internalInstance;
66
+ }
67
+
68
+ /**
69
+ * ReactUpdateQueue allows for state updates to be scheduled into a later
70
+ * reconciliation step.
71
+ */
72
+ var ReactUpdateQueue = {
73
+
74
+ /**
75
+ * Enqueue a callback that will be executed after all the pending updates
76
+ * have processed.
77
+ *
78
+ * @param {ReactClass} publicInstance The instance to use as `this` context.
79
+ * @param {?function} callback Called after state is updated.
80
+ * @internal
81
+ */
82
+ enqueueCallback: function(publicInstance, callback) {
83
+ ("production" !== process.env.NODE_ENV ? invariant(
84
+ typeof callback === 'function',
85
+ 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
86
+ '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
87
+ 'isn\'t callable.'
88
+ ) : invariant(typeof callback === 'function'));
89
+ var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
90
+
91
+ // Previously we would throw an error if we didn't have an internal
92
+ // instance. Since we want to make it a no-op instead, we mirror the same
93
+ // behavior we have in other enqueue* methods.
94
+ // We also need to ignore callbacks in componentWillMount. See
95
+ // enqueueUpdates.
96
+ if (!internalInstance ||
97
+ internalInstance === ReactLifeCycle.currentlyMountingInstance) {
98
+ return null;
99
+ }
100
+
101
+ if (internalInstance._pendingCallbacks) {
102
+ internalInstance._pendingCallbacks.push(callback);
103
+ } else {
104
+ internalInstance._pendingCallbacks = [callback];
105
+ }
106
+ // TODO: The callback here is ignored when setState is called from
107
+ // componentWillMount. Either fix it or disallow doing so completely in
108
+ // favor of getInitialState. Alternatively, we can disallow
109
+ // componentWillMount during server-side rendering.
110
+ enqueueUpdate(internalInstance);
111
+ },
112
+
113
+ enqueueCallbackInternal: function(internalInstance, callback) {
114
+ ("production" !== process.env.NODE_ENV ? invariant(
115
+ typeof callback === 'function',
116
+ 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
117
+ '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
118
+ 'isn\'t callable.'
119
+ ) : invariant(typeof callback === 'function'));
120
+ if (internalInstance._pendingCallbacks) {
121
+ internalInstance._pendingCallbacks.push(callback);
122
+ } else {
123
+ internalInstance._pendingCallbacks = [callback];
124
+ }
125
+ enqueueUpdate(internalInstance);
126
+ },
127
+
128
+ /**
129
+ * Forces an update. This should only be invoked when it is known with
130
+ * certainty that we are **not** in a DOM transaction.
131
+ *
132
+ * You may want to call this when you know that some deeper aspect of the
133
+ * component's state has changed but `setState` was not called.
134
+ *
135
+ * This will not invoke `shouldUpdateComponent`, but it will invoke
136
+ * `componentWillUpdate` and `componentDidUpdate`.
137
+ *
138
+ * @param {ReactClass} publicInstance The instance that should rerender.
139
+ * @internal
140
+ */
141
+ enqueueForceUpdate: function(publicInstance) {
142
+ var internalInstance = getInternalInstanceReadyForUpdate(
143
+ publicInstance,
144
+ 'forceUpdate'
145
+ );
146
+
147
+ if (!internalInstance) {
148
+ return;
149
+ }
150
+
151
+ internalInstance._pendingForceUpdate = true;
152
+
153
+ enqueueUpdate(internalInstance);
154
+ },
155
+
156
+ /**
157
+ * Replaces all of the state. Always use this or `setState` to mutate state.
158
+ * You should treat `this.state` as immutable.
159
+ *
160
+ * There is no guarantee that `this.state` will be immediately updated, so
161
+ * accessing `this.state` after calling this method may return the old value.
162
+ *
163
+ * @param {ReactClass} publicInstance The instance that should rerender.
164
+ * @param {object} completeState Next state.
165
+ * @internal
166
+ */
167
+ enqueueReplaceState: function(publicInstance, completeState) {
168
+ var internalInstance = getInternalInstanceReadyForUpdate(
169
+ publicInstance,
170
+ 'replaceState'
171
+ );
172
+
173
+ if (!internalInstance) {
174
+ return;
175
+ }
176
+
177
+ internalInstance._pendingStateQueue = [completeState];
178
+ internalInstance._pendingReplaceState = true;
179
+
180
+ enqueueUpdate(internalInstance);
181
+ },
182
+
183
+ /**
184
+ * Sets a subset of the state. This only exists because _pendingState is
185
+ * internal. This provides a merging strategy that is not available to deep
186
+ * properties which is confusing. TODO: Expose pendingState or don't use it
187
+ * during the merge.
188
+ *
189
+ * @param {ReactClass} publicInstance The instance that should rerender.
190
+ * @param {object} partialState Next partial state to be merged with state.
191
+ * @internal
192
+ */
193
+ enqueueSetState: function(publicInstance, partialState) {
194
+ var internalInstance = getInternalInstanceReadyForUpdate(
195
+ publicInstance,
196
+ 'setState'
197
+ );
198
+
199
+ if (!internalInstance) {
200
+ return;
201
+ }
202
+
203
+ var queue =
204
+ internalInstance._pendingStateQueue ||
205
+ (internalInstance._pendingStateQueue = []);
206
+ queue.push(partialState);
207
+
208
+ enqueueUpdate(internalInstance);
209
+ },
210
+
211
+ /**
212
+ * Sets a subset of the props.
213
+ *
214
+ * @param {ReactClass} publicInstance The instance that should rerender.
215
+ * @param {object} partialProps Subset of the next props.
216
+ * @internal
217
+ */
218
+ enqueueSetProps: function(publicInstance, partialProps) {
219
+ var internalInstance = getInternalInstanceReadyForUpdate(
220
+ publicInstance,
221
+ 'setProps'
222
+ );
223
+
224
+ if (!internalInstance) {
225
+ return;
226
+ }
227
+
228
+ ("production" !== process.env.NODE_ENV ? invariant(
229
+ internalInstance._isTopLevel,
230
+ 'setProps(...): You called `setProps` on a ' +
231
+ 'component with a parent. This is an anti-pattern since props will ' +
232
+ 'get reactively updated when rendered. Instead, change the owner\'s ' +
233
+ '`render` method to pass the correct value as props to the component ' +
234
+ 'where it is created.'
235
+ ) : invariant(internalInstance._isTopLevel));
236
+
237
+ // Merge with the pending element if it exists, otherwise with existing
238
+ // element props.
239
+ var element = internalInstance._pendingElement ||
240
+ internalInstance._currentElement;
241
+ var props = assign({}, element.props, partialProps);
242
+ internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
243
+ element,
244
+ props
245
+ );
246
+
247
+ enqueueUpdate(internalInstance);
248
+ },
249
+
250
+ /**
251
+ * Replaces all of the props.
252
+ *
253
+ * @param {ReactClass} publicInstance The instance that should rerender.
254
+ * @param {object} props New props.
255
+ * @internal
256
+ */
257
+ enqueueReplaceProps: function(publicInstance, props) {
258
+ var internalInstance = getInternalInstanceReadyForUpdate(
259
+ publicInstance,
260
+ 'replaceProps'
261
+ );
262
+
263
+ if (!internalInstance) {
264
+ return;
265
+ }
266
+
267
+ ("production" !== process.env.NODE_ENV ? invariant(
268
+ internalInstance._isTopLevel,
269
+ 'replaceProps(...): You called `replaceProps` on a ' +
270
+ 'component with a parent. This is an anti-pattern since props will ' +
271
+ 'get reactively updated when rendered. Instead, change the owner\'s ' +
272
+ '`render` method to pass the correct value as props to the component ' +
273
+ 'where it is created.'
274
+ ) : invariant(internalInstance._isTopLevel));
275
+
276
+ // Merge with the pending element if it exists, otherwise with existing
277
+ // element props.
278
+ var element = internalInstance._pendingElement ||
279
+ internalInstance._currentElement;
280
+ internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
281
+ element,
282
+ props
283
+ );
284
+
285
+ enqueueUpdate(internalInstance);
286
+ },
287
+
288
+ enqueueElementInternal: function(internalInstance, newElement) {
289
+ internalInstance._pendingElement = newElement;
290
+ enqueueUpdate(internalInstance);
291
+ }
292
+
293
+ };
294
+
295
+ module.exports = ReactUpdateQueue;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -9,12 +9,13 @@
9
9
  * @providesModule ReactUpdates
10
10
  */
11
11
 
12
- "use strict";
12
+ 'use strict';
13
13
 
14
14
  var CallbackQueue = require("./CallbackQueue");
15
15
  var PooledClass = require("./PooledClass");
16
16
  var ReactCurrentOwner = require("./ReactCurrentOwner");
17
17
  var ReactPerf = require("./ReactPerf");
18
+ var ReactReconciler = require("./ReactReconciler");
18
19
  var Transaction = require("./Transaction");
19
20
 
20
21
  var assign = require("./Object.assign");
@@ -104,20 +105,20 @@ assign(
104
105
 
105
106
  PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
106
107
 
107
- function batchedUpdates(callback, a, b) {
108
+ function batchedUpdates(callback, a, b, c, d) {
108
109
  ensureInjected();
109
- batchingStrategy.batchedUpdates(callback, a, b);
110
+ batchingStrategy.batchedUpdates(callback, a, b, c, d);
110
111
  }
111
112
 
112
113
  /**
113
- * Array comparator for ReactComponents by owner depth
114
+ * Array comparator for ReactComponents by mount ordering.
114
115
  *
115
116
  * @param {ReactComponent} c1 first component you're comparing
116
117
  * @param {ReactComponent} c2 second component you're comparing
117
118
  * @return {number} Return value usable by Array.prototype.sort().
118
119
  */
119
- function mountDepthComparator(c1, c2) {
120
- return c1._mountDepth - c2._mountDepth;
120
+ function mountOrderComparator(c1, c2) {
121
+ return c1._mountOrder - c2._mountOrder;
121
122
  }
122
123
 
123
124
  function runBatchedUpdates(transaction) {
@@ -133,69 +134,68 @@ function runBatchedUpdates(transaction) {
133
134
  // Since reconciling a component higher in the owner hierarchy usually (not
134
135
  // always -- see shouldComponentUpdate()) will reconcile children, reconcile
135
136
  // them before their children by sorting the array.
136
- dirtyComponents.sort(mountDepthComparator);
137
+ dirtyComponents.sort(mountOrderComparator);
137
138
 
138
139
  for (var i = 0; i < len; i++) {
139
- // If a component is unmounted before pending changes apply, ignore them
140
- // TODO: Queue unmounts in the same list to avoid this happening at all
140
+ // If a component is unmounted before pending changes apply, it will still
141
+ // be here, but we assume that it has cleared its _pendingCallbacks and
142
+ // that performUpdateIfNecessary is a noop.
141
143
  var component = dirtyComponents[i];
142
- if (component.isMounted()) {
143
- // If performUpdateIfNecessary happens to enqueue any new updates, we
144
- // shouldn't execute the callbacks until the next render happens, so
145
- // stash the callbacks first
146
- var callbacks = component._pendingCallbacks;
147
- component._pendingCallbacks = null;
148
- component.performUpdateIfNecessary(transaction.reconcileTransaction);
149
-
150
- if (callbacks) {
151
- for (var j = 0; j < callbacks.length; j++) {
152
- transaction.callbackQueue.enqueue(
153
- callbacks[j],
154
- component
155
- );
156
- }
144
+
145
+ // If performUpdateIfNecessary happens to enqueue any new updates, we
146
+ // shouldn't execute the callbacks until the next render happens, so
147
+ // stash the callbacks first
148
+ var callbacks = component._pendingCallbacks;
149
+ component._pendingCallbacks = null;
150
+
151
+ ReactReconciler.performUpdateIfNecessary(
152
+ component,
153
+ transaction.reconcileTransaction
154
+ );
155
+
156
+ if (callbacks) {
157
+ for (var j = 0; j < callbacks.length; j++) {
158
+ transaction.callbackQueue.enqueue(
159
+ callbacks[j],
160
+ component.getPublicInstance()
161
+ );
157
162
  }
158
163
  }
159
164
  }
160
165
  }
161
166
 
162
- var flushBatchedUpdates = ReactPerf.measure(
163
- 'ReactUpdates',
164
- 'flushBatchedUpdates',
165
- 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
- }
167
+ var flushBatchedUpdates = function() {
168
+ // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
169
+ // array and perform any updates enqueued by mount-ready handlers (i.e.,
170
+ // componentDidUpdate) but we need to check here too in order to catch
171
+ // updates enqueued by setState callbacks and asap calls.
172
+ while (dirtyComponents.length || asapEnqueued) {
173
+ if (dirtyComponents.length) {
174
+ var transaction = ReactUpdatesFlushTransaction.getPooled();
175
+ transaction.perform(runBatchedUpdates, null, transaction);
176
+ ReactUpdatesFlushTransaction.release(transaction);
177
+ }
176
178
 
177
- if (asapEnqueued) {
178
- asapEnqueued = false;
179
- var queue = asapCallbackQueue;
180
- asapCallbackQueue = CallbackQueue.getPooled();
181
- queue.notifyAll();
182
- CallbackQueue.release(queue);
183
- }
179
+ if (asapEnqueued) {
180
+ asapEnqueued = false;
181
+ var queue = asapCallbackQueue;
182
+ asapCallbackQueue = CallbackQueue.getPooled();
183
+ queue.notifyAll();
184
+ CallbackQueue.release(queue);
184
185
  }
185
186
  }
187
+ };
188
+ flushBatchedUpdates = ReactPerf.measure(
189
+ 'ReactUpdates',
190
+ 'flushBatchedUpdates',
191
+ flushBatchedUpdates
186
192
  );
187
193
 
188
194
  /**
189
195
  * Mark a component as needing a rerender, adding an optional callback to a
190
196
  * list of functions which will be executed once the rerender occurs.
191
197
  */
192
- function enqueueUpdate(component, callback) {
193
- ("production" !== process.env.NODE_ENV ? invariant(
194
- !callback || typeof callback === "function",
195
- 'enqueueUpdate(...): You called `setProps`, `replaceProps`, ' +
196
- '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
197
- 'isn\'t callable.'
198
- ) : invariant(!callback || typeof callback === "function"));
198
+ function enqueueUpdate(component) {
199
199
  ensureInjected();
200
200
 
201
201
  // Various parts of our code (such as ReactCompositeComponent's
@@ -212,19 +212,11 @@ function enqueueUpdate(component, callback) {
212
212
  ) : null);
213
213
 
214
214
  if (!batchingStrategy.isBatchingUpdates) {
215
- batchingStrategy.batchedUpdates(enqueueUpdate, component, callback);
215
+ batchingStrategy.batchedUpdates(enqueueUpdate, component);
216
216
  return;
217
217
  }
218
218
 
219
219
  dirtyComponents.push(component);
220
-
221
- if (callback) {
222
- if (component._pendingCallbacks) {
223
- component._pendingCallbacks.push(callback);
224
- } else {
225
- component._pendingCallbacks = [callback];
226
- }
227
- }
228
220
  }
229
221
 
230
222
  /**