react 0.14.10 → 15.0.0

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 (193) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +4900 -4627
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +4556 -4059
  5. package/dist/react.min.js +7 -7
  6. package/lib/AutoFocusUtils.js +3 -15
  7. package/lib/BeforeInputEventPlugin.js +8 -25
  8. package/lib/CSSProperty.js +10 -1
  9. package/lib/CSSPropertyOperations.js +49 -19
  10. package/lib/CallbackQueue.js +16 -4
  11. package/lib/ChangeEventPlugin.js +58 -54
  12. package/lib/DOMChildrenOperations.js +91 -61
  13. package/lib/DOMLazyTree.js +105 -0
  14. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  15. package/lib/DOMProperty.js +18 -39
  16. package/lib/DOMPropertyOperations.js +42 -53
  17. package/lib/Danger.js +13 -14
  18. package/lib/DefaultEventPluginOrder.js +1 -1
  19. package/lib/EnterLeaveEventPlugin.js +24 -43
  20. package/lib/EventConstants.js +6 -1
  21. package/lib/EventPluginHub.js +22 -66
  22. package/lib/EventPluginRegistry.js +30 -9
  23. package/lib/EventPluginUtils.js +61 -36
  24. package/lib/EventPropagators.js +19 -17
  25. package/lib/FallbackCompositionState.js +4 -4
  26. package/lib/HTMLDOMPropertyConfig.js +131 -152
  27. package/lib/LinkedStateMixin.js +1 -2
  28. package/lib/LinkedValueUtils.js +6 -7
  29. package/lib/MetaMatchers.js +2 -2
  30. package/lib/OrderedMap.js +17 -16
  31. package/lib/PooledClass.js +2 -2
  32. package/lib/React.js +50 -20
  33. package/lib/ReactBrowserEventEmitter.js +19 -26
  34. package/lib/ReactCSSTransitionGroup.js +4 -5
  35. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  36. package/lib/ReactChildReconciler.js +15 -13
  37. package/lib/ReactChildren.js +5 -4
  38. package/lib/ReactClass.js +44 -92
  39. package/lib/ReactComponent.js +9 -10
  40. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  41. package/lib/ReactComponentEnvironment.js +4 -4
  42. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  43. package/lib/ReactCompositeComponent.js +166 -74
  44. package/lib/ReactCurrentOwner.js +2 -1
  45. package/lib/ReactDOM.js +27 -15
  46. package/lib/ReactDOMButton.js +2 -2
  47. package/lib/ReactDOMComponent.js +186 -250
  48. package/lib/ReactDOMComponentFlags.js +18 -0
  49. package/lib/ReactDOMComponentTree.js +186 -0
  50. package/lib/ReactDOMContainerInfo.js +32 -0
  51. package/lib/ReactDOMDebugTool.js +61 -0
  52. package/lib/ReactDOMEmptyComponent.js +60 -0
  53. package/lib/ReactDOMFactories.js +1 -2
  54. package/lib/ReactDOMFeatureFlags.js +2 -2
  55. package/lib/ReactDOMIDOperations.js +5 -60
  56. package/lib/ReactDOMInput.js +73 -23
  57. package/lib/ReactDOMInstrumentation.js +16 -0
  58. package/lib/ReactDOMOption.js +14 -12
  59. package/lib/ReactDOMSelect.js +43 -19
  60. package/lib/ReactDOMSelection.js +4 -4
  61. package/lib/ReactDOMServer.js +1 -1
  62. package/lib/ReactDOMTextComponent.js +87 -45
  63. package/lib/ReactDOMTextarea.js +39 -11
  64. package/lib/ReactDOMTreeTraversal.js +134 -0
  65. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  66. package/lib/ReactDebugInstanceMap.js +102 -0
  67. package/lib/ReactDebugTool.js +72 -0
  68. package/lib/ReactDefaultBatchingStrategy.js +4 -3
  69. package/lib/ReactDefaultInjection.js +11 -15
  70. package/lib/ReactDefaultPerf.js +105 -26
  71. package/lib/ReactDefaultPerfAnalysis.js +23 -15
  72. package/lib/ReactElement.js +63 -23
  73. package/lib/ReactElementValidator.js +9 -9
  74. package/lib/ReactEmptyComponent.js +8 -33
  75. package/lib/ReactErrorUtils.js +1 -2
  76. package/lib/ReactEventEmitterMixin.js +3 -8
  77. package/lib/ReactEventListener.js +23 -77
  78. package/lib/ReactFeatureFlags.js +21 -0
  79. package/lib/ReactFragment.js +6 -6
  80. package/lib/ReactInjection.js +3 -3
  81. package/lib/ReactInputSelection.js +4 -4
  82. package/lib/ReactInstanceHandles.js +10 -12
  83. package/lib/ReactInstanceMap.js +2 -1
  84. package/lib/ReactInstrumentation.js +16 -0
  85. package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
  86. package/lib/ReactLink.js +2 -3
  87. package/lib/ReactMarkupChecksum.js +8 -3
  88. package/lib/ReactMount.js +88 -460
  89. package/lib/ReactMultiChild.js +106 -200
  90. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  91. package/lib/ReactNativeComponent.js +6 -5
  92. package/lib/ReactNodeTypes.js +37 -0
  93. package/lib/ReactNoopUpdateQueue.js +2 -25
  94. package/lib/ReactOwner.js +7 -6
  95. package/lib/ReactPerf.js +2 -2
  96. package/lib/ReactPropTransferer.js +5 -4
  97. package/lib/ReactPropTypeLocationNames.js +1 -1
  98. package/lib/ReactPropTypeLocations.js +1 -1
  99. package/lib/ReactPropTypes.js +31 -7
  100. package/lib/ReactReconcileTransaction.js +20 -9
  101. package/lib/ReactReconciler.js +29 -6
  102. package/lib/ReactRef.js +1 -1
  103. package/lib/ReactServerBatchingStrategy.js +1 -2
  104. package/lib/ReactServerRendering.js +17 -35
  105. package/lib/ReactServerRenderingTransaction.js +11 -29
  106. package/lib/ReactSimpleEmptyComponent.js +36 -0
  107. package/lib/ReactStateSetters.js +1 -1
  108. package/lib/ReactTestUtils.js +47 -28
  109. package/lib/ReactTransitionChildMapping.js +1 -2
  110. package/lib/ReactTransitionEvents.js +8 -44
  111. package/lib/ReactTransitionGroup.js +4 -3
  112. package/lib/ReactUMDEntry.js +26 -0
  113. package/lib/ReactUpdateQueue.js +24 -66
  114. package/lib/ReactUpdates.js +29 -11
  115. package/lib/ReactVersion.js +2 -2
  116. package/lib/ReactWithAddons.js +1 -21
  117. package/lib/ReactWithAddonsUMDEntry.js +26 -0
  118. package/lib/ResponderEventPlugin.js +54 -66
  119. package/lib/ResponderSyntheticEvent.js +2 -3
  120. package/lib/ResponderTouchHistoryStore.js +5 -5
  121. package/lib/SVGDOMPropertyConfig.js +267 -94
  122. package/lib/SelectEventPlugin.js +13 -18
  123. package/lib/SimpleEventPlugin.js +57 -17
  124. package/lib/SyntheticAnimationEvent.js +39 -0
  125. package/lib/SyntheticClipboardEvent.js +2 -3
  126. package/lib/SyntheticCompositionEvent.js +2 -3
  127. package/lib/SyntheticDragEvent.js +2 -3
  128. package/lib/SyntheticEvent.js +102 -21
  129. package/lib/SyntheticFocusEvent.js +2 -3
  130. package/lib/SyntheticInputEvent.js +2 -3
  131. package/lib/SyntheticKeyboardEvent.js +2 -3
  132. package/lib/SyntheticMouseEvent.js +2 -3
  133. package/lib/SyntheticTouchEvent.js +2 -3
  134. package/lib/SyntheticTransitionEvent.js +39 -0
  135. package/lib/SyntheticUIEvent.js +2 -3
  136. package/lib/SyntheticWheelEvent.js +2 -3
  137. package/lib/TapEventPlugin.js +3 -12
  138. package/lib/Transaction.js +3 -3
  139. package/lib/ViewportMetrics.js +1 -1
  140. package/lib/accumulate.js +2 -2
  141. package/lib/accumulateInto.js +2 -2
  142. package/lib/adler32.js +3 -2
  143. package/lib/canDefineProperty.js +1 -1
  144. package/lib/createHierarchyRenderer.js +1 -1
  145. package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
  146. package/lib/dangerousStyleValue.js +25 -3
  147. package/lib/deprecated.js +7 -4
  148. package/lib/escapeTextContentForBrowser.js +1 -1
  149. package/lib/findDOMNode.js +15 -8
  150. package/lib/flattenChildren.js +2 -2
  151. package/lib/forEachAccumulated.js +2 -1
  152. package/lib/getEventCharCode.js +2 -2
  153. package/lib/getEventKey.js +1 -2
  154. package/lib/getEventModifierState.js +1 -2
  155. package/lib/getEventTarget.js +8 -2
  156. package/lib/getIteratorFn.js +2 -2
  157. package/lib/getNativeComponentFromComposite.js +30 -0
  158. package/lib/getNodeForCharacterOffset.js +2 -1
  159. package/lib/getTestDocument.js +1 -1
  160. package/lib/getTextContentAccessor.js +1 -1
  161. package/lib/getVendorPrefixedEventName.js +101 -0
  162. package/lib/instantiateReactComponent.js +12 -13
  163. package/lib/isEventSupported.js +2 -2
  164. package/lib/isTextInputElement.js +2 -1
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/quoteAttributeValueForBrowser.js +1 -1
  167. package/lib/reactComponentExpect.js +5 -4
  168. package/lib/renderSubtreeIntoContainer.js +1 -1
  169. package/lib/setInnerHTML.js +6 -14
  170. package/lib/setTextContent.js +1 -1
  171. package/lib/shallowCompare.js +1 -1
  172. package/lib/shouldUpdateReactComponent.js +2 -3
  173. package/lib/sliceChildren.js +1 -1
  174. package/lib/traverseAllChildren.js +8 -8
  175. package/lib/update.js +16 -15
  176. package/lib/validateDOMNesting.js +18 -13
  177. package/package.json +23 -32
  178. package/addons.js +0 -13
  179. package/cjs/react-jsx-dev-runtime.development.js +0 -861
  180. package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  181. package/cjs/react-jsx-runtime.development.js +0 -883
  182. package/cjs/react-jsx-runtime.production.min.js +0 -10
  183. package/jsx-dev-runtime.js +0 -7
  184. package/jsx-runtime.js +0 -7
  185. package/lib/Object.assign.js +0 -47
  186. package/lib/React.native.js +0 -5
  187. package/lib/ReactBrowserComponentMixin.js +0 -36
  188. package/lib/ReactEmptyComponentRegistry.js +0 -48
  189. package/lib/ReactIsomorphic.js +0 -74
  190. package/lib/ReactRootIndex.js +0 -29
  191. package/lib/ServerReactRootIndex.js +0 -29
  192. package/lib/cloneWithProps.js +0 -54
  193. package/lib/webcomponents.js +0 -6379
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,7 +7,6 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactMultiChild
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
@@ -20,156 +19,119 @@ var ReactReconciler = require('./ReactReconciler');
20
19
  var ReactChildReconciler = require('./ReactChildReconciler');
21
20
 
22
21
  var flattenChildren = require('./flattenChildren');
22
+ var invariant = require('fbjs/lib/invariant');
23
23
 
24
24
  /**
25
- * Updating children of a component may trigger recursive updates. The depth is
26
- * used to batch recursive updates to render markup more efficiently.
25
+ * Make an update for markup to be rendered and inserted at a supplied index.
27
26
  *
28
- * @type {number}
29
- * @private
30
- */
31
- var updateDepth = 0;
32
-
33
- /**
34
- * Queue of update configuration objects.
35
- *
36
- * Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
37
- *
38
- * @type {array<object>}
39
- * @private
40
- */
41
- var updateQueue = [];
42
-
43
- /**
44
- * Queue of markup to be rendered.
45
- *
46
- * @type {array<string>}
47
- * @private
48
- */
49
- var markupQueue = [];
50
-
51
- /**
52
- * Enqueues markup to be rendered and inserted at a supplied index.
53
- *
54
- * @param {string} parentID ID of the parent component.
55
27
  * @param {string} markup Markup that renders into an element.
56
28
  * @param {number} toIndex Destination index.
57
29
  * @private
58
30
  */
59
- function enqueueInsertMarkup(parentID, markup, toIndex) {
31
+ function makeInsertMarkup(markup, afterNode, toIndex) {
60
32
  // NOTE: Null values reduce hidden classes.
61
- updateQueue.push({
62
- parentID: parentID,
63
- parentNode: null,
33
+ return {
64
34
  type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
65
- markupIndex: markupQueue.push(markup) - 1,
66
- content: null,
35
+ content: markup,
67
36
  fromIndex: null,
68
- toIndex: toIndex
69
- });
37
+ fromNode: null,
38
+ toIndex: toIndex,
39
+ afterNode: afterNode
40
+ };
70
41
  }
71
42
 
72
43
  /**
73
- * Enqueues moving an existing element to another index.
44
+ * Make an update for moving an existing element to another index.
74
45
  *
75
- * @param {string} parentID ID of the parent component.
76
46
  * @param {number} fromIndex Source index of the existing element.
77
47
  * @param {number} toIndex Destination index of the element.
78
48
  * @private
79
49
  */
80
- function enqueueMove(parentID, fromIndex, toIndex) {
50
+ function makeMove(child, afterNode, toIndex) {
81
51
  // NOTE: Null values reduce hidden classes.
82
- updateQueue.push({
83
- parentID: parentID,
84
- parentNode: null,
52
+ return {
85
53
  type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
86
- markupIndex: null,
87
54
  content: null,
88
- fromIndex: fromIndex,
89
- toIndex: toIndex
90
- });
55
+ fromIndex: child._mountIndex,
56
+ fromNode: ReactReconciler.getNativeNode(child),
57
+ toIndex: toIndex,
58
+ afterNode: afterNode
59
+ };
91
60
  }
92
61
 
93
62
  /**
94
- * Enqueues removing an element at an index.
63
+ * Make an update for removing an element at an index.
95
64
  *
96
- * @param {string} parentID ID of the parent component.
97
65
  * @param {number} fromIndex Index of the element to remove.
98
66
  * @private
99
67
  */
100
- function enqueueRemove(parentID, fromIndex) {
68
+ function makeRemove(child, node) {
101
69
  // NOTE: Null values reduce hidden classes.
102
- updateQueue.push({
103
- parentID: parentID,
104
- parentNode: null,
70
+ return {
105
71
  type: ReactMultiChildUpdateTypes.REMOVE_NODE,
106
- markupIndex: null,
107
72
  content: null,
108
- fromIndex: fromIndex,
109
- toIndex: null
110
- });
73
+ fromIndex: child._mountIndex,
74
+ fromNode: node,
75
+ toIndex: null,
76
+ afterNode: null
77
+ };
111
78
  }
112
79
 
113
80
  /**
114
- * Enqueues setting the markup of a node.
81
+ * Make an update for setting the markup of a node.
115
82
  *
116
- * @param {string} parentID ID of the parent component.
117
83
  * @param {string} markup Markup that renders into an element.
118
84
  * @private
119
85
  */
120
- function enqueueSetMarkup(parentID, markup) {
86
+ function makeSetMarkup(markup) {
121
87
  // NOTE: Null values reduce hidden classes.
122
- updateQueue.push({
123
- parentID: parentID,
124
- parentNode: null,
88
+ return {
125
89
  type: ReactMultiChildUpdateTypes.SET_MARKUP,
126
- markupIndex: null,
127
90
  content: markup,
128
91
  fromIndex: null,
129
- toIndex: null
130
- });
92
+ fromNode: null,
93
+ toIndex: null,
94
+ afterNode: null
95
+ };
131
96
  }
132
97
 
133
98
  /**
134
- * Enqueues setting the text content.
99
+ * Make an update for setting the text content.
135
100
  *
136
- * @param {string} parentID ID of the parent component.
137
101
  * @param {string} textContent Text content to set.
138
102
  * @private
139
103
  */
140
- function enqueueTextContent(parentID, textContent) {
104
+ function makeTextContent(textContent) {
141
105
  // NOTE: Null values reduce hidden classes.
142
- updateQueue.push({
143
- parentID: parentID,
144
- parentNode: null,
106
+ return {
145
107
  type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
146
- markupIndex: null,
147
108
  content: textContent,
148
109
  fromIndex: null,
149
- toIndex: null
150
- });
110
+ fromNode: null,
111
+ toIndex: null,
112
+ afterNode: null
113
+ };
151
114
  }
152
115
 
153
116
  /**
154
- * Processes any enqueued updates.
155
- *
156
- * @private
117
+ * Push an update, if any, onto the queue. Creates a new queue if none is
118
+ * passed and always returns the queue. Mutative.
157
119
  */
158
- function processQueue() {
159
- if (updateQueue.length) {
160
- ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);
161
- clearQueue();
120
+ function enqueue(queue, update) {
121
+ if (update) {
122
+ queue = queue || [];
123
+ queue.push(update);
162
124
  }
125
+ return queue;
163
126
  }
164
127
 
165
128
  /**
166
- * Clears any enqueued updates.
129
+ * Processes any enqueued updates.
167
130
  *
168
131
  * @private
169
132
  */
170
- function clearQueue() {
171
- updateQueue.length = 0;
172
- markupQueue.length = 0;
133
+ function processQueue(inst, updateQueue) {
134
+ ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);
173
135
  }
174
136
 
175
137
  /**
@@ -203,7 +165,7 @@ var ReactMultiChild = {
203
165
  return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
204
166
  },
205
167
 
206
- _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, transaction, context) {
168
+ _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, removedNodes, transaction, context) {
207
169
  var nextChildren;
208
170
  if (process.env.NODE_ENV !== 'production') {
209
171
  if (this._currentElement) {
@@ -213,11 +175,13 @@ var ReactMultiChild = {
213
175
  } finally {
214
176
  ReactCurrentOwner.current = null;
215
177
  }
216
- return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
178
+ ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
179
+ return nextChildren;
217
180
  }
218
181
  }
219
182
  nextChildren = flattenChildren(nextNestedChildrenElements);
220
- return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
183
+ ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
184
+ return nextChildren;
221
185
  },
222
186
 
223
187
  /**
@@ -236,9 +200,7 @@ var ReactMultiChild = {
236
200
  for (var name in children) {
237
201
  if (children.hasOwnProperty(name)) {
238
202
  var child = children[name];
239
- // Inlined for performance, see `ReactInstanceHandles.createReactID`.
240
- var rootID = this._rootNodeID + name;
241
- var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
203
+ var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._nativeContainerInfo, context);
242
204
  child._mountIndex = index++;
243
205
  mountImages.push(mountImage);
244
206
  }
@@ -253,31 +215,17 @@ var ReactMultiChild = {
253
215
  * @internal
254
216
  */
255
217
  updateTextContent: function (nextContent) {
256
- updateDepth++;
257
- var errorThrown = true;
258
- try {
259
- var prevChildren = this._renderedChildren;
260
- // Remove any rendered children.
261
- ReactChildReconciler.unmountChildren(prevChildren);
262
- // TODO: The setTextContent operation should be enough
263
- for (var name in prevChildren) {
264
- if (prevChildren.hasOwnProperty(name)) {
265
- this._unmountChild(prevChildren[name]);
266
- }
267
- }
268
- // Set new text content.
269
- this.setTextContent(nextContent);
270
- errorThrown = false;
271
- } finally {
272
- updateDepth--;
273
- if (!updateDepth) {
274
- if (errorThrown) {
275
- clearQueue();
276
- } else {
277
- processQueue();
278
- }
218
+ var prevChildren = this._renderedChildren;
219
+ // Remove any rendered children.
220
+ ReactChildReconciler.unmountChildren(prevChildren, false);
221
+ for (var name in prevChildren) {
222
+ if (prevChildren.hasOwnProperty(name)) {
223
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : invariant(false) : void 0;
279
224
  }
280
225
  }
226
+ // Set new text content.
227
+ var updates = [makeTextContent(nextContent)];
228
+ processQueue(this, updates);
281
229
  },
282
230
 
283
231
  /**
@@ -287,29 +235,16 @@ var ReactMultiChild = {
287
235
  * @internal
288
236
  */
289
237
  updateMarkup: function (nextMarkup) {
290
- updateDepth++;
291
- var errorThrown = true;
292
- try {
293
- var prevChildren = this._renderedChildren;
294
- // Remove any rendered children.
295
- ReactChildReconciler.unmountChildren(prevChildren);
296
- for (var name in prevChildren) {
297
- if (prevChildren.hasOwnProperty(name)) {
298
- this._unmountChildByName(prevChildren[name], name);
299
- }
300
- }
301
- this.setMarkup(nextMarkup);
302
- errorThrown = false;
303
- } finally {
304
- updateDepth--;
305
- if (!updateDepth) {
306
- if (errorThrown) {
307
- clearQueue();
308
- } else {
309
- processQueue();
310
- }
238
+ var prevChildren = this._renderedChildren;
239
+ // Remove any rendered children.
240
+ ReactChildReconciler.unmountChildren(prevChildren, false);
241
+ for (var name in prevChildren) {
242
+ if (prevChildren.hasOwnProperty(name)) {
243
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : invariant(false) : void 0;
311
244
  }
312
245
  }
246
+ var updates = [makeSetMarkup(nextMarkup)];
247
+ processQueue(this, updates);
313
248
  },
314
249
 
315
250
  /**
@@ -320,27 +255,11 @@ var ReactMultiChild = {
320
255
  * @internal
321
256
  */
322
257
  updateChildren: function (nextNestedChildrenElements, transaction, context) {
323
- updateDepth++;
324
- var errorThrown = true;
325
- try {
326
- this._updateChildren(nextNestedChildrenElements, transaction, context);
327
- errorThrown = false;
328
- } finally {
329
- updateDepth--;
330
- if (!updateDepth) {
331
- if (errorThrown) {
332
- clearQueue();
333
- } else {
334
- processQueue();
335
- }
336
- }
337
- }
258
+ // Hook used by React ART
259
+ this._updateChildren(nextNestedChildrenElements, transaction, context);
338
260
  },
339
261
 
340
262
  /**
341
- * Improve performance by isolating this hot code path from the try/catch
342
- * block in `updateChildren`.
343
- *
344
263
  * @param {?object} nextNestedChildrenElements Nested child element maps.
345
264
  * @param {ReactReconcileTransaction} transaction
346
265
  * @final
@@ -348,16 +267,18 @@ var ReactMultiChild = {
348
267
  */
349
268
  _updateChildren: function (nextNestedChildrenElements, transaction, context) {
350
269
  var prevChildren = this._renderedChildren;
351
- var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, transaction, context);
352
- this._renderedChildren = nextChildren;
270
+ var removedNodes = {};
271
+ var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, removedNodes, transaction, context);
353
272
  if (!nextChildren && !prevChildren) {
354
273
  return;
355
274
  }
275
+ var updates = null;
356
276
  var name;
357
277
  // `nextIndex` will increment for each child in `nextChildren`, but
358
278
  // `lastIndex` will be the last index visited in `prevChildren`.
359
279
  var lastIndex = 0;
360
280
  var nextIndex = 0;
281
+ var lastPlacedNode = null;
361
282
  for (name in nextChildren) {
362
283
  if (!nextChildren.hasOwnProperty(name)) {
363
284
  continue;
@@ -365,37 +286,43 @@ var ReactMultiChild = {
365
286
  var prevChild = prevChildren && prevChildren[name];
366
287
  var nextChild = nextChildren[name];
367
288
  if (prevChild === nextChild) {
368
- this.moveChild(prevChild, nextIndex, lastIndex);
289
+ updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex));
369
290
  lastIndex = Math.max(prevChild._mountIndex, lastIndex);
370
291
  prevChild._mountIndex = nextIndex;
371
292
  } else {
372
293
  if (prevChild) {
373
294
  // Update `lastIndex` before `_mountIndex` gets unset by unmounting.
374
295
  lastIndex = Math.max(prevChild._mountIndex, lastIndex);
375
- this._unmountChild(prevChild);
296
+ // The `removedNodes` loop below will actually remove the child.
376
297
  }
377
298
  // The child must be instantiated before it's mounted.
378
- this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context);
299
+ updates = enqueue(updates, this._mountChildAtIndex(nextChild, lastPlacedNode, nextIndex, transaction, context));
379
300
  }
380
301
  nextIndex++;
302
+ lastPlacedNode = ReactReconciler.getNativeNode(nextChild);
381
303
  }
382
304
  // Remove children that are no longer present.
383
- for (name in prevChildren) {
384
- if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
385
- this._unmountChild(prevChildren[name]);
305
+ for (name in removedNodes) {
306
+ if (removedNodes.hasOwnProperty(name)) {
307
+ updates = enqueue(updates, this._unmountChild(prevChildren[name], removedNodes[name]));
386
308
  }
387
309
  }
310
+ if (updates) {
311
+ processQueue(this, updates);
312
+ }
313
+ this._renderedChildren = nextChildren;
388
314
  },
389
315
 
390
316
  /**
391
317
  * Unmounts all rendered children. This should be used to clean up children
392
- * when this component is unmounted.
318
+ * when this component is unmounted. It does not actually perform any
319
+ * backend operations.
393
320
  *
394
321
  * @internal
395
322
  */
396
- unmountChildren: function () {
323
+ unmountChildren: function (safely) {
397
324
  var renderedChildren = this._renderedChildren;
398
- ReactChildReconciler.unmountChildren(renderedChildren);
325
+ ReactChildReconciler.unmountChildren(renderedChildren, safely);
399
326
  this._renderedChildren = null;
400
327
  },
401
328
 
@@ -407,12 +334,12 @@ var ReactMultiChild = {
407
334
  * @param {number} lastIndex Last index visited of the siblings of `child`.
408
335
  * @protected
409
336
  */
410
- moveChild: function (child, toIndex, lastIndex) {
337
+ moveChild: function (child, afterNode, toIndex, lastIndex) {
411
338
  // If the index of `child` is less than `lastIndex`, then it needs to
412
339
  // be moved. Otherwise, we do not need to move it because a child will be
413
340
  // inserted or moved before `child`.
414
341
  if (child._mountIndex < lastIndex) {
415
- enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
342
+ return makeMove(child, afterNode, toIndex);
416
343
  }
417
344
  },
418
345
 
@@ -423,8 +350,8 @@ var ReactMultiChild = {
423
350
  * @param {string} mountImage Markup to insert.
424
351
  * @protected
425
352
  */
426
- createChild: function (child, mountImage) {
427
- enqueueInsertMarkup(this._rootNodeID, mountImage, child._mountIndex);
353
+ createChild: function (child, afterNode, mountImage) {
354
+ return makeInsertMarkup(mountImage, afterNode, child._mountIndex);
428
355
  },
429
356
 
430
357
  /**
@@ -433,28 +360,8 @@ var ReactMultiChild = {
433
360
  * @param {ReactComponent} child Child to remove.
434
361
  * @protected
435
362
  */
436
- removeChild: function (child) {
437
- enqueueRemove(this._rootNodeID, child._mountIndex);
438
- },
439
-
440
- /**
441
- * Sets this text content string.
442
- *
443
- * @param {string} textContent Text content to set.
444
- * @protected
445
- */
446
- setTextContent: function (textContent) {
447
- enqueueTextContent(this._rootNodeID, textContent);
448
- },
449
-
450
- /**
451
- * Sets this markup string.
452
- *
453
- * @param {string} markup Markup to set.
454
- * @protected
455
- */
456
- setMarkup: function (markup) {
457
- enqueueSetMarkup(this._rootNodeID, markup);
363
+ removeChild: function (child, node) {
364
+ return makeRemove(child, node);
458
365
  },
459
366
 
460
367
  /**
@@ -468,12 +375,10 @@ var ReactMultiChild = {
468
375
  * @param {ReactReconcileTransaction} transaction
469
376
  * @private
470
377
  */
471
- _mountChildByNameAtIndex: function (child, name, index, transaction, context) {
472
- // Inlined for performance, see `ReactInstanceHandles.createReactID`.
473
- var rootID = this._rootNodeID + name;
474
- var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
378
+ _mountChildAtIndex: function (child, afterNode, index, transaction, context) {
379
+ var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._nativeContainerInfo, context);
475
380
  child._mountIndex = index;
476
- this.createChild(child, mountImage);
381
+ return this.createChild(child, afterNode, mountImage);
477
382
  },
478
383
 
479
384
  /**
@@ -484,9 +389,10 @@ var ReactMultiChild = {
484
389
  * @param {ReactComponent} child Component to unmount.
485
390
  * @private
486
391
  */
487
- _unmountChild: function (child) {
488
- this.removeChild(child);
392
+ _unmountChild: function (child, node) {
393
+ var update = this.removeChild(child, node);
489
394
  child._mountIndex = null;
395
+ return update;
490
396
  }
491
397
 
492
398
  }