react 15.3.2-rc.1 → 15.4.0-rc.3

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 (209) hide show
  1. package/dist/react-with-addons.js +3863 -21388
  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/sliceChildren.js +0 -1
  52. package/lib/traverseAllChildren.js +11 -3
  53. package/lib/update.js +6 -8
  54. package/package.json +1 -1
  55. package/lib/AutoFocusUtils.js +0 -24
  56. package/lib/BeforeInputEventPlugin.js +0 -390
  57. package/lib/CSSProperty.js +0 -148
  58. package/lib/CSSPropertyOperations.js +0 -205
  59. package/lib/CallbackQueue.js +0 -106
  60. package/lib/ChangeEventPlugin.js +0 -325
  61. package/lib/DOMChildrenOperations.js +0 -194
  62. package/lib/DOMLazyTree.js +0 -118
  63. package/lib/DOMProperty.js +0 -206
  64. package/lib/DOMPropertyOperations.js +0 -221
  65. package/lib/Danger.js +0 -48
  66. package/lib/DefaultEventPluginOrder.js +0 -27
  67. package/lib/DisabledInputUtils.js +0 -50
  68. package/lib/EnterLeaveEventPlugin.js +0 -105
  69. package/lib/EventConstants.js +0 -97
  70. package/lib/EventPluginHub.js +0 -251
  71. package/lib/EventPluginRegistry.js +0 -247
  72. package/lib/EventPluginUtils.js +0 -229
  73. package/lib/EventPropagators.js +0 -137
  74. package/lib/FallbackCompositionState.js +0 -95
  75. package/lib/HTMLDOMPropertyConfig.js +0 -212
  76. package/lib/LinkedValueUtils.js +0 -136
  77. package/lib/NativeMethodsMixin.js +0 -167
  78. package/lib/ReactBrowserEventEmitter.js +0 -330
  79. package/lib/ReactChildReconciler.js +0 -154
  80. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  81. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  82. package/lib/ReactComponentEnvironment.js +0 -45
  83. package/lib/ReactComponentTreeTestUtils.js +0 -87
  84. package/lib/ReactCompositeComponent.js +0 -904
  85. package/lib/ReactDOM.js +0 -110
  86. package/lib/ReactDOMButton.js +0 -24
  87. package/lib/ReactDOMComponent.js +0 -1006
  88. package/lib/ReactDOMComponentTree.js +0 -188
  89. package/lib/ReactDOMContainerInfo.js +0 -33
  90. package/lib/ReactDOMEmptyComponent.js +0 -60
  91. package/lib/ReactDOMFiber.js +0 -76
  92. package/lib/ReactDOMIDOperations.js +0 -34
  93. package/lib/ReactDOMInput.js +0 -269
  94. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  95. package/lib/ReactDOMOption.js +0 -123
  96. package/lib/ReactDOMSelect.js +0 -201
  97. package/lib/ReactDOMSelection.js +0 -212
  98. package/lib/ReactDOMServer.js +0 -26
  99. package/lib/ReactDOMTextComponent.js +0 -164
  100. package/lib/ReactDOMTextarea.js +0 -155
  101. package/lib/ReactDOMTreeTraversal.js +0 -136
  102. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  103. package/lib/ReactDebugTool.js +0 -301
  104. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  105. package/lib/ReactDefaultInjection.js +0 -84
  106. package/lib/ReactEmptyComponent.js +0 -30
  107. package/lib/ReactErrorUtils.js +0 -76
  108. package/lib/ReactEventEmitterMixin.js +0 -33
  109. package/lib/ReactEventListener.js +0 -157
  110. package/lib/ReactFeatureFlags.js +0 -22
  111. package/lib/ReactHostComponent.js +0 -76
  112. package/lib/ReactHostOperationHistoryHook.js +0 -37
  113. package/lib/ReactInjection.js +0 -36
  114. package/lib/ReactInputSelection.js +0 -124
  115. package/lib/ReactInstanceHandles.js +0 -302
  116. package/lib/ReactInstanceMap.js +0 -48
  117. package/lib/ReactInstrumentation.js +0 -21
  118. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  119. package/lib/ReactMarkupChecksum.js +0 -50
  120. package/lib/ReactMount.js +0 -534
  121. package/lib/ReactMultiChild.js +0 -451
  122. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  123. package/lib/ReactNative.js +0 -71
  124. package/lib/ReactNativeAttributePayload.js +0 -371
  125. package/lib/ReactNativeBaseComponent.js +0 -198
  126. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  127. package/lib/ReactNativeComponentEnvironment.js +0 -31
  128. package/lib/ReactNativeComponentTree.js +0 -68
  129. package/lib/ReactNativeContainerInfo.js +0 -21
  130. package/lib/ReactNativeDOMIDOperations.js +0 -79
  131. package/lib/ReactNativeDefaultInjection.js +0 -101
  132. package/lib/ReactNativeEventEmitter.js +0 -191
  133. package/lib/ReactNativeEventPluginOrder.js +0 -16
  134. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  135. package/lib/ReactNativeMount.js +0 -193
  136. package/lib/ReactNativePropRegistry.js +0 -52
  137. package/lib/ReactNativeReconcileTransaction.js +0 -129
  138. package/lib/ReactNativeTagHandles.js +0 -56
  139. package/lib/ReactNativeTextComponent.js +0 -71
  140. package/lib/ReactNativeTreeTraversal.js +0 -127
  141. package/lib/ReactNodeTypes.js +0 -40
  142. package/lib/ReactNoop.js +0 -173
  143. package/lib/ReactOwner.js +0 -94
  144. package/lib/ReactPerf.js +0 -494
  145. package/lib/ReactReconcileTransaction.js +0 -178
  146. package/lib/ReactReconciler.js +0 -168
  147. package/lib/ReactRef.js +0 -80
  148. package/lib/ReactServerBatchingStrategy.js +0 -22
  149. package/lib/ReactServerRendering.js +0 -90
  150. package/lib/ReactServerRenderingTransaction.js +0 -90
  151. package/lib/ReactServerUpdateQueue.js +0 -141
  152. package/lib/ReactSimpleEmptyComponent.js +0 -37
  153. package/lib/ReactTestMount.js +0 -126
  154. package/lib/ReactTestReconcileTransaction.js +0 -121
  155. package/lib/ReactTestRenderer.js +0 -144
  156. package/lib/ReactTestUtils.js +0 -518
  157. package/lib/ReactUpdateQueue.js +0 -226
  158. package/lib/ReactUpdates.js +0 -251
  159. package/lib/ResponderEventPlugin.js +0 -510
  160. package/lib/ResponderSyntheticEvent.js +0 -39
  161. package/lib/ResponderTouchHistoryStore.js +0 -184
  162. package/lib/SVGDOMPropertyConfig.js +0 -302
  163. package/lib/SelectEventPlugin.js +0 -196
  164. package/lib/SimpleEventPlugin.js +0 -635
  165. package/lib/SyntheticAnimationEvent.js +0 -39
  166. package/lib/SyntheticClipboardEvent.js +0 -38
  167. package/lib/SyntheticCompositionEvent.js +0 -36
  168. package/lib/SyntheticDragEvent.js +0 -36
  169. package/lib/SyntheticEvent.js +0 -268
  170. package/lib/SyntheticFocusEvent.js +0 -36
  171. package/lib/SyntheticInputEvent.js +0 -37
  172. package/lib/SyntheticKeyboardEvent.js +0 -84
  173. package/lib/SyntheticMouseEvent.js +0 -72
  174. package/lib/SyntheticTouchEvent.js +0 -45
  175. package/lib/SyntheticTransitionEvent.js +0 -39
  176. package/lib/SyntheticUIEvent.js +0 -59
  177. package/lib/SyntheticWheelEvent.js +0 -54
  178. package/lib/TapEventPlugin.js +0 -110
  179. package/lib/TouchHistoryMath.js +0 -99
  180. package/lib/Transaction.js +0 -233
  181. package/lib/ViewportMetrics.js +0 -27
  182. package/lib/accumulate.js +0 -46
  183. package/lib/accumulateInto.js +0 -58
  184. package/lib/adler32.js +0 -44
  185. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  186. package/lib/createReactNativeComponentClass.js +0 -42
  187. package/lib/dangerousStyleValue.js +0 -79
  188. package/lib/escapeTextContentForBrowser.js +0 -123
  189. package/lib/findDOMNode.js +0 -60
  190. package/lib/findNodeHandle.js +0 -91
  191. package/lib/forEachAccumulated.js +0 -31
  192. package/lib/getEventCharCode.js +0 -50
  193. package/lib/getEventKey.js +0 -102
  194. package/lib/getEventModifierState.js +0 -43
  195. package/lib/getEventTarget.js +0 -35
  196. package/lib/getHostComponentFromComposite.js +0 -30
  197. package/lib/getNodeForCharacterOffset.js +0 -74
  198. package/lib/getTestDocument.js +0 -21
  199. package/lib/getTextContentAccessor.js +0 -33
  200. package/lib/getVendorPrefixedEventName.js +0 -101
  201. package/lib/instantiateReactComponent.js +0 -119
  202. package/lib/isEventSupported.js +0 -60
  203. package/lib/isTextInputElement.js +0 -51
  204. package/lib/quoteAttributeValueForBrowser.js +0 -26
  205. package/lib/reactComponentExpect.js +0 -217
  206. package/lib/setInnerHTML.js +0 -98
  207. package/lib/setTextContent.js +0 -48
  208. package/lib/shouldUpdateReactComponent.js +0 -42
  209. package/lib/validateDOMNesting.js +0 -382
@@ -1,451 +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 ReactMultiChild
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant');
15
-
16
- var ReactComponentEnvironment = require('./ReactComponentEnvironment');
17
- var ReactInstanceMap = require('./ReactInstanceMap');
18
- var ReactInstrumentation = require('./ReactInstrumentation');
19
- var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
20
-
21
- var ReactCurrentOwner = require('./ReactCurrentOwner');
22
- var ReactReconciler = require('./ReactReconciler');
23
- var ReactChildReconciler = require('./ReactChildReconciler');
24
-
25
- var emptyFunction = require('fbjs/lib/emptyFunction');
26
- var flattenChildren = require('./flattenChildren');
27
- var invariant = require('fbjs/lib/invariant');
28
-
29
- /**
30
- * Make an update for markup to be rendered and inserted at a supplied index.
31
- *
32
- * @param {string} markup Markup that renders into an element.
33
- * @param {number} toIndex Destination index.
34
- * @private
35
- */
36
- function makeInsertMarkup(markup, afterNode, toIndex) {
37
- // NOTE: Null values reduce hidden classes.
38
- return {
39
- type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
40
- content: markup,
41
- fromIndex: null,
42
- fromNode: null,
43
- toIndex: toIndex,
44
- afterNode: afterNode
45
- };
46
- }
47
-
48
- /**
49
- * Make an update for moving an existing element to another index.
50
- *
51
- * @param {number} fromIndex Source index of the existing element.
52
- * @param {number} toIndex Destination index of the element.
53
- * @private
54
- */
55
- function makeMove(child, afterNode, toIndex) {
56
- // NOTE: Null values reduce hidden classes.
57
- return {
58
- type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
59
- content: null,
60
- fromIndex: child._mountIndex,
61
- fromNode: ReactReconciler.getHostNode(child),
62
- toIndex: toIndex,
63
- afterNode: afterNode
64
- };
65
- }
66
-
67
- /**
68
- * Make an update for removing an element at an index.
69
- *
70
- * @param {number} fromIndex Index of the element to remove.
71
- * @private
72
- */
73
- function makeRemove(child, node) {
74
- // NOTE: Null values reduce hidden classes.
75
- return {
76
- type: ReactMultiChildUpdateTypes.REMOVE_NODE,
77
- content: null,
78
- fromIndex: child._mountIndex,
79
- fromNode: node,
80
- toIndex: null,
81
- afterNode: null
82
- };
83
- }
84
-
85
- /**
86
- * Make an update for setting the markup of a node.
87
- *
88
- * @param {string} markup Markup that renders into an element.
89
- * @private
90
- */
91
- function makeSetMarkup(markup) {
92
- // NOTE: Null values reduce hidden classes.
93
- return {
94
- type: ReactMultiChildUpdateTypes.SET_MARKUP,
95
- content: markup,
96
- fromIndex: null,
97
- fromNode: null,
98
- toIndex: null,
99
- afterNode: null
100
- };
101
- }
102
-
103
- /**
104
- * Make an update for setting the text content.
105
- *
106
- * @param {string} textContent Text content to set.
107
- * @private
108
- */
109
- function makeTextContent(textContent) {
110
- // NOTE: Null values reduce hidden classes.
111
- return {
112
- type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
113
- content: textContent,
114
- fromIndex: null,
115
- fromNode: null,
116
- toIndex: null,
117
- afterNode: null
118
- };
119
- }
120
-
121
- /**
122
- * Push an update, if any, onto the queue. Creates a new queue if none is
123
- * passed and always returns the queue. Mutative.
124
- */
125
- function enqueue(queue, update) {
126
- if (update) {
127
- queue = queue || [];
128
- queue.push(update);
129
- }
130
- return queue;
131
- }
132
-
133
- /**
134
- * Processes any enqueued updates.
135
- *
136
- * @private
137
- */
138
- function processQueue(inst, updateQueue) {
139
- ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);
140
- }
141
-
142
- var setChildrenForInstrumentation = emptyFunction;
143
- if (process.env.NODE_ENV !== 'production') {
144
- var getDebugID = function (inst) {
145
- if (!inst._debugID) {
146
- // Check for ART-like instances. TODO: This is silly/gross.
147
- var internal;
148
- if (internal = ReactInstanceMap.get(inst)) {
149
- inst = internal;
150
- }
151
- }
152
- return inst._debugID;
153
- };
154
- setChildrenForInstrumentation = function (children) {
155
- var debugID = getDebugID(this);
156
- // TODO: React Native empty components are also multichild.
157
- // This means they still get into this method but don't have _debugID.
158
- if (debugID !== 0) {
159
- ReactInstrumentation.debugTool.onSetChildren(debugID, children ? Object.keys(children).map(function (key) {
160
- return children[key]._debugID;
161
- }) : []);
162
- }
163
- };
164
- }
165
-
166
- /**
167
- * ReactMultiChild are capable of reconciling multiple children.
168
- *
169
- * @class ReactMultiChild
170
- * @internal
171
- */
172
- var ReactMultiChild = {
173
-
174
- /**
175
- * Provides common functionality for components that must reconcile multiple
176
- * children. This is used by `ReactDOMComponent` to mount, update, and
177
- * unmount child components.
178
- *
179
- * @lends {ReactMultiChild.prototype}
180
- */
181
- Mixin: {
182
-
183
- _reconcilerInstantiateChildren: function (nestedChildren, transaction, context) {
184
- if (process.env.NODE_ENV !== 'production') {
185
- var selfDebugID = getDebugID(this);
186
- if (this._currentElement) {
187
- try {
188
- ReactCurrentOwner.current = this._currentElement._owner;
189
- return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context, selfDebugID);
190
- } finally {
191
- ReactCurrentOwner.current = null;
192
- }
193
- }
194
- }
195
- return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
196
- },
197
-
198
- _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context) {
199
- var nextChildren;
200
- var selfDebugID = 0;
201
- if (process.env.NODE_ENV !== 'production') {
202
- selfDebugID = getDebugID(this);
203
- if (this._currentElement) {
204
- try {
205
- ReactCurrentOwner.current = this._currentElement._owner;
206
- nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);
207
- } finally {
208
- ReactCurrentOwner.current = null;
209
- }
210
- ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);
211
- return nextChildren;
212
- }
213
- }
214
- nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);
215
- ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);
216
- return nextChildren;
217
- },
218
-
219
- /**
220
- * Generates a "mount image" for each of the supplied children. In the case
221
- * of `ReactDOMComponent`, a mount image is a string of markup.
222
- *
223
- * @param {?object} nestedChildren Nested child maps.
224
- * @return {array} An array of mounted representations.
225
- * @internal
226
- */
227
- mountChildren: function (nestedChildren, transaction, context) {
228
- var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context);
229
- this._renderedChildren = children;
230
-
231
- var mountImages = [];
232
- var index = 0;
233
- for (var name in children) {
234
- if (children.hasOwnProperty(name)) {
235
- var child = children[name];
236
- var selfDebugID = 0;
237
- if (process.env.NODE_ENV !== 'production') {
238
- selfDebugID = getDebugID(this);
239
- }
240
- var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context, selfDebugID);
241
- child._mountIndex = index++;
242
- mountImages.push(mountImage);
243
- }
244
- }
245
-
246
- if (process.env.NODE_ENV !== 'production') {
247
- setChildrenForInstrumentation.call(this, children);
248
- }
249
-
250
- return mountImages;
251
- },
252
-
253
- /**
254
- * Replaces any rendered children with a text content string.
255
- *
256
- * @param {string} nextContent String of content.
257
- * @internal
258
- */
259
- updateTextContent: function (nextContent) {
260
- var prevChildren = this._renderedChildren;
261
- // Remove any rendered children.
262
- ReactChildReconciler.unmountChildren(prevChildren, false);
263
- for (var name in prevChildren) {
264
- if (prevChildren.hasOwnProperty(name)) {
265
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : _prodInvariant('118') : void 0;
266
- }
267
- }
268
- // Set new text content.
269
- var updates = [makeTextContent(nextContent)];
270
- processQueue(this, updates);
271
- },
272
-
273
- /**
274
- * Replaces any rendered children with a markup string.
275
- *
276
- * @param {string} nextMarkup String of markup.
277
- * @internal
278
- */
279
- updateMarkup: function (nextMarkup) {
280
- var prevChildren = this._renderedChildren;
281
- // Remove any rendered children.
282
- ReactChildReconciler.unmountChildren(prevChildren, false);
283
- for (var name in prevChildren) {
284
- if (prevChildren.hasOwnProperty(name)) {
285
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : _prodInvariant('118') : void 0;
286
- }
287
- }
288
- var updates = [makeSetMarkup(nextMarkup)];
289
- processQueue(this, updates);
290
- },
291
-
292
- /**
293
- * Updates the rendered children with new children.
294
- *
295
- * @param {?object} nextNestedChildrenElements Nested child element maps.
296
- * @param {ReactReconcileTransaction} transaction
297
- * @internal
298
- */
299
- updateChildren: function (nextNestedChildrenElements, transaction, context) {
300
- // Hook used by React ART
301
- this._updateChildren(nextNestedChildrenElements, transaction, context);
302
- },
303
-
304
- /**
305
- * @param {?object} nextNestedChildrenElements Nested child element maps.
306
- * @param {ReactReconcileTransaction} transaction
307
- * @final
308
- * @protected
309
- */
310
- _updateChildren: function (nextNestedChildrenElements, transaction, context) {
311
- var prevChildren = this._renderedChildren;
312
- var removedNodes = {};
313
- var mountImages = [];
314
- var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context);
315
- if (!nextChildren && !prevChildren) {
316
- return;
317
- }
318
- var updates = null;
319
- var name;
320
- // `nextIndex` will increment for each child in `nextChildren`, but
321
- // `lastIndex` will be the last index visited in `prevChildren`.
322
- var nextIndex = 0;
323
- var lastIndex = 0;
324
- // `nextMountIndex` will increment for each newly mounted child.
325
- var nextMountIndex = 0;
326
- var lastPlacedNode = null;
327
- for (name in nextChildren) {
328
- if (!nextChildren.hasOwnProperty(name)) {
329
- continue;
330
- }
331
- var prevChild = prevChildren && prevChildren[name];
332
- var nextChild = nextChildren[name];
333
- if (prevChild === nextChild) {
334
- updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex));
335
- lastIndex = Math.max(prevChild._mountIndex, lastIndex);
336
- prevChild._mountIndex = nextIndex;
337
- } else {
338
- if (prevChild) {
339
- // Update `lastIndex` before `_mountIndex` gets unset by unmounting.
340
- lastIndex = Math.max(prevChild._mountIndex, lastIndex);
341
- // The `removedNodes` loop below will actually remove the child.
342
- }
343
- // The child must be instantiated before it's mounted.
344
- updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context));
345
- nextMountIndex++;
346
- }
347
- nextIndex++;
348
- lastPlacedNode = ReactReconciler.getHostNode(nextChild);
349
- }
350
- // Remove children that are no longer present.
351
- for (name in removedNodes) {
352
- if (removedNodes.hasOwnProperty(name)) {
353
- updates = enqueue(updates, this._unmountChild(prevChildren[name], removedNodes[name]));
354
- }
355
- }
356
- if (updates) {
357
- processQueue(this, updates);
358
- }
359
- this._renderedChildren = nextChildren;
360
-
361
- if (process.env.NODE_ENV !== 'production') {
362
- setChildrenForInstrumentation.call(this, nextChildren);
363
- }
364
- },
365
-
366
- /**
367
- * Unmounts all rendered children. This should be used to clean up children
368
- * when this component is unmounted. It does not actually perform any
369
- * backend operations.
370
- *
371
- * @internal
372
- */
373
- unmountChildren: function (safely) {
374
- var renderedChildren = this._renderedChildren;
375
- ReactChildReconciler.unmountChildren(renderedChildren, safely);
376
- this._renderedChildren = null;
377
- },
378
-
379
- /**
380
- * Moves a child component to the supplied index.
381
- *
382
- * @param {ReactComponent} child Component to move.
383
- * @param {number} toIndex Destination index of the element.
384
- * @param {number} lastIndex Last index visited of the siblings of `child`.
385
- * @protected
386
- */
387
- moveChild: function (child, afterNode, toIndex, lastIndex) {
388
- // If the index of `child` is less than `lastIndex`, then it needs to
389
- // be moved. Otherwise, we do not need to move it because a child will be
390
- // inserted or moved before `child`.
391
- if (child._mountIndex < lastIndex) {
392
- return makeMove(child, afterNode, toIndex);
393
- }
394
- },
395
-
396
- /**
397
- * Creates a child component.
398
- *
399
- * @param {ReactComponent} child Component to create.
400
- * @param {string} mountImage Markup to insert.
401
- * @protected
402
- */
403
- createChild: function (child, afterNode, mountImage) {
404
- return makeInsertMarkup(mountImage, afterNode, child._mountIndex);
405
- },
406
-
407
- /**
408
- * Removes a child component.
409
- *
410
- * @param {ReactComponent} child Child to remove.
411
- * @protected
412
- */
413
- removeChild: function (child, node) {
414
- return makeRemove(child, node);
415
- },
416
-
417
- /**
418
- * Mounts a child with the supplied name.
419
- *
420
- * NOTE: This is part of `updateChildren` and is here for readability.
421
- *
422
- * @param {ReactComponent} child Component to mount.
423
- * @param {string} name Name of the child.
424
- * @param {number} index Index at which to insert the child.
425
- * @param {ReactReconcileTransaction} transaction
426
- * @private
427
- */
428
- _mountChildAtIndex: function (child, mountImage, afterNode, index, transaction, context) {
429
- child._mountIndex = index;
430
- return this.createChild(child, afterNode, mountImage);
431
- },
432
-
433
- /**
434
- * Unmounts a rendered child.
435
- *
436
- * NOTE: This is part of `updateChildren` and is here for readability.
437
- *
438
- * @param {ReactComponent} child Component to unmount.
439
- * @private
440
- */
441
- _unmountChild: function (child, node) {
442
- var update = this.removeChild(child, node);
443
- child._mountIndex = null;
444
- return update;
445
- }
446
-
447
- }
448
-
449
- };
450
-
451
- module.exports = ReactMultiChild;
@@ -1,32 +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 ReactMultiChildUpdateTypes
10
- */
11
-
12
- 'use strict';
13
-
14
- var keyMirror = require('fbjs/lib/keyMirror');
15
-
16
- /**
17
- * When a component's children are updated, a series of update configuration
18
- * objects are created in order to batch and serialize the required changes.
19
- *
20
- * Enumerates all the possible types of update configurations.
21
- *
22
- * @internal
23
- */
24
- var ReactMultiChildUpdateTypes = keyMirror({
25
- INSERT_MARKUP: null,
26
- MOVE_EXISTING: null,
27
- REMOVE_NODE: null,
28
- SET_MARKUP: null,
29
- TEXT_CONTENT: null
30
- });
31
-
32
- module.exports = ReactMultiChildUpdateTypes;