react-test-renderer 15.5.0 → 15.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/lib/ReactShallowRenderer.js +6 -0
  2. package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
  3. package/lib/shallow/AutoFocusUtils.js +23 -0
  4. package/lib/shallow/BeforeInputEventPlugin.js +384 -0
  5. package/lib/shallow/CSSProperty.js +147 -0
  6. package/lib/shallow/CSSPropertyOperations.js +208 -0
  7. package/lib/shallow/CallbackQueue.js +118 -0
  8. package/lib/shallow/ChangeEventPlugin.js +345 -0
  9. package/lib/shallow/DOMChildrenOperations.js +224 -0
  10. package/lib/shallow/DOMLazyTree.js +117 -0
  11. package/lib/shallow/DOMNamespaces.js +19 -0
  12. package/lib/shallow/DOMProperty.js +209 -0
  13. package/lib/shallow/DOMPropertyOperations.js +236 -0
  14. package/lib/shallow/Danger.js +47 -0
  15. package/lib/shallow/DefaultEventPluginOrder.js +25 -0
  16. package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
  17. package/lib/shallow/EventConstants.js +91 -0
  18. package/lib/shallow/EventPluginHub.js +277 -0
  19. package/lib/shallow/EventPluginRegistry.js +254 -0
  20. package/lib/shallow/EventPluginUtils.js +225 -0
  21. package/lib/shallow/EventPropagators.js +133 -0
  22. package/lib/shallow/FallbackCompositionState.js +94 -0
  23. package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
  24. package/lib/shallow/KeyEscapeUtils.js +58 -0
  25. package/lib/shallow/LinkedValueUtils.js +137 -0
  26. package/lib/shallow/PluginModuleType.js +12 -0
  27. package/lib/shallow/PooledClass.js +111 -0
  28. package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
  29. package/lib/shallow/ReactChildFiber.js +243 -0
  30. package/lib/shallow/ReactChildReconciler.js +153 -0
  31. package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
  32. package/lib/shallow/ReactComponentEnvironment.js +45 -0
  33. package/lib/shallow/ReactCompositeComponent.js +901 -0
  34. package/lib/shallow/ReactCoroutine.js +80 -0
  35. package/lib/shallow/ReactDOM.js +110 -0
  36. package/lib/shallow/ReactDOMComponent.js +1000 -0
  37. package/lib/shallow/ReactDOMComponentFlags.js +17 -0
  38. package/lib/shallow/ReactDOMComponentTree.js +194 -0
  39. package/lib/shallow/ReactDOMContainerInfo.js +32 -0
  40. package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
  41. package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
  42. package/lib/shallow/ReactDOMFiber.js +97 -0
  43. package/lib/shallow/ReactDOMIDOperations.js +33 -0
  44. package/lib/shallow/ReactDOMInput.js +284 -0
  45. package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
  46. package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
  47. package/lib/shallow/ReactDOMOption.js +122 -0
  48. package/lib/shallow/ReactDOMSelect.js +199 -0
  49. package/lib/shallow/ReactDOMSelection.js +211 -0
  50. package/lib/shallow/ReactDOMServer.js +25 -0
  51. package/lib/shallow/ReactDOMTextComponent.js +163 -0
  52. package/lib/shallow/ReactDOMTextarea.js +159 -0
  53. package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
  54. package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
  55. package/lib/shallow/ReactDebugTool.js +358 -0
  56. package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
  57. package/lib/shallow/ReactDefaultInjection.js +85 -0
  58. package/lib/shallow/ReactElementSymbol.js +19 -0
  59. package/lib/shallow/ReactEmptyComponent.js +29 -0
  60. package/lib/shallow/ReactErrorUtils.js +75 -0
  61. package/lib/shallow/ReactEventEmitterMixin.js +32 -0
  62. package/lib/shallow/ReactEventListener.js +154 -0
  63. package/lib/shallow/ReactFeatureFlags.js +21 -0
  64. package/lib/shallow/ReactFiber.js +190 -0
  65. package/lib/shallow/ReactFiberBeginWork.js +380 -0
  66. package/lib/shallow/ReactFiberCommitWork.js +78 -0
  67. package/lib/shallow/ReactFiberCompleteWork.js +208 -0
  68. package/lib/shallow/ReactFiberReconciler.js +64 -0
  69. package/lib/shallow/ReactFiberRoot.js +29 -0
  70. package/lib/shallow/ReactFiberScheduler.js +331 -0
  71. package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
  72. package/lib/shallow/ReactHostComponent.js +67 -0
  73. package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
  74. package/lib/shallow/ReactInjection.js +33 -0
  75. package/lib/shallow/ReactInputSelection.js +123 -0
  76. package/lib/shallow/ReactInstanceMap.js +47 -0
  77. package/lib/shallow/ReactInstanceType.js +12 -0
  78. package/lib/shallow/ReactInstrumentation.js +23 -0
  79. package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
  80. package/lib/shallow/ReactMarkupChecksum.js +49 -0
  81. package/lib/shallow/ReactMount.js +537 -0
  82. package/lib/shallow/ReactMultiChild.js +449 -0
  83. package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
  84. package/lib/shallow/ReactNodeTypes.js +39 -0
  85. package/lib/shallow/ReactOwner.js +93 -0
  86. package/lib/shallow/ReactPerf.js +500 -0
  87. package/lib/shallow/ReactPriorityLevel.js +20 -0
  88. package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
  89. package/lib/shallow/ReactPropTypeLocations.js +12 -0
  90. package/lib/shallow/ReactPropTypesSecret.js +16 -0
  91. package/lib/shallow/ReactReconcileTransaction.js +177 -0
  92. package/lib/shallow/ReactReconciler.js +167 -0
  93. package/lib/shallow/ReactRef.js +88 -0
  94. package/lib/shallow/ReactReifiedYield.js +30 -0
  95. package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
  96. package/lib/shallow/ReactServerRendering.js +89 -0
  97. package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
  98. package/lib/shallow/ReactServerUpdateQueue.js +138 -0
  99. package/lib/shallow/ReactShallowRenderer.js +150 -0
  100. package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
  101. package/lib/shallow/ReactSyntheticEventType.js +14 -0
  102. package/lib/shallow/ReactTestEmptyComponent.js +36 -0
  103. package/lib/shallow/ReactTestMount.js +131 -0
  104. package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
  105. package/lib/shallow/ReactTestRenderer.js +139 -0
  106. package/lib/shallow/ReactTestTextComponent.js +40 -0
  107. package/lib/shallow/ReactTypeOfWork.js +23 -0
  108. package/lib/shallow/ReactTypes.js +12 -0
  109. package/lib/shallow/ReactUpdateQueue.js +235 -0
  110. package/lib/shallow/ReactUpdates.js +250 -0
  111. package/lib/shallow/ReactVersion.js +13 -0
  112. package/lib/shallow/ResponderEventPlugin.js +507 -0
  113. package/lib/shallow/ResponderSyntheticEvent.js +38 -0
  114. package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
  115. package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
  116. package/lib/shallow/SelectEventPlugin.js +190 -0
  117. package/lib/shallow/SimpleEventPlugin.js +227 -0
  118. package/lib/shallow/SyntheticAnimationEvent.js +38 -0
  119. package/lib/shallow/SyntheticClipboardEvent.js +37 -0
  120. package/lib/shallow/SyntheticCompositionEvent.js +35 -0
  121. package/lib/shallow/SyntheticDragEvent.js +35 -0
  122. package/lib/shallow/SyntheticEvent.js +267 -0
  123. package/lib/shallow/SyntheticFocusEvent.js +35 -0
  124. package/lib/shallow/SyntheticInputEvent.js +36 -0
  125. package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
  126. package/lib/shallow/SyntheticMouseEvent.js +71 -0
  127. package/lib/shallow/SyntheticTouchEvent.js +44 -0
  128. package/lib/shallow/SyntheticTransitionEvent.js +38 -0
  129. package/lib/shallow/SyntheticUIEvent.js +58 -0
  130. package/lib/shallow/SyntheticWheelEvent.js +53 -0
  131. package/lib/shallow/TapEventPlugin.js +115 -0
  132. package/lib/shallow/TouchHistoryMath.js +98 -0
  133. package/lib/shallow/Transaction.js +224 -0
  134. package/lib/shallow/ViewportMetrics.js +26 -0
  135. package/lib/shallow/accumulate.js +45 -0
  136. package/lib/shallow/accumulateInto.js +57 -0
  137. package/lib/shallow/adler32.js +43 -0
  138. package/lib/shallow/canDefineProperty.js +25 -0
  139. package/lib/shallow/checkReactTypeSpec.js +86 -0
  140. package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
  141. package/lib/shallow/dangerousStyleValue.js +78 -0
  142. package/lib/shallow/deprecated.js +56 -0
  143. package/lib/shallow/escapeTextContentForBrowser.js +122 -0
  144. package/lib/shallow/findDOMNode.js +59 -0
  145. package/lib/shallow/flattenChildren.js +75 -0
  146. package/lib/shallow/forEachAccumulated.js +30 -0
  147. package/lib/shallow/getEventCharCode.js +49 -0
  148. package/lib/shallow/getEventKey.js +101 -0
  149. package/lib/shallow/getEventModifierState.js +42 -0
  150. package/lib/shallow/getEventTarget.js +34 -0
  151. package/lib/shallow/getHostComponentFromComposite.js +29 -0
  152. package/lib/shallow/getIteratorFn.js +40 -0
  153. package/lib/shallow/getNodeForCharacterOffset.js +73 -0
  154. package/lib/shallow/getTextContentAccessor.js +32 -0
  155. package/lib/shallow/getVendorPrefixedEventName.js +100 -0
  156. package/lib/shallow/instantiateReactComponent.js +128 -0
  157. package/lib/shallow/isEventSupported.js +59 -0
  158. package/lib/shallow/isTextInputElement.js +50 -0
  159. package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
  160. package/lib/shallow/reactProdInvariant.js +38 -0
  161. package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
  162. package/lib/shallow/setInnerHTML.js +97 -0
  163. package/lib/shallow/setTextContent.js +51 -0
  164. package/lib/shallow/shouldUpdateReactComponent.js +41 -0
  165. package/lib/shallow/traverseAllChildren.js +175 -0
  166. package/lib/shallow/validateDOMNesting.js +376 -0
  167. package/package.json +1 -1
  168. package/shallow.js +1 -1
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var REACT_ELEMENT_TYPE = require('./ReactElementSymbol');
15
+
16
+ var _require = require('./ReactCoroutine'),
17
+ REACT_COROUTINE_TYPE = _require.REACT_COROUTINE_TYPE,
18
+ REACT_YIELD_TYPE = _require.REACT_YIELD_TYPE;
19
+
20
+ var ReactFiber = require('./ReactFiber');
21
+ var ReactReifiedYield = require('./ReactReifiedYield');
22
+
23
+ var cloneFiber = ReactFiber.cloneFiber,
24
+ createFiberFromElement = ReactFiber.createFiberFromElement,
25
+ createFiberFromCoroutine = ReactFiber.createFiberFromCoroutine,
26
+ createFiberFromYield = ReactFiber.createFiberFromYield;
27
+ var createReifiedYield = ReactReifiedYield.createReifiedYield;
28
+
29
+
30
+ var isArray = Array.isArray;
31
+
32
+ function ChildReconciler(shouldClone) {
33
+
34
+ function createSubsequentChild(returnFiber, existingChild, previousSibling, newChildren, priority) {
35
+ if (typeof newChildren !== 'object' || newChildren === null) {
36
+ return previousSibling;
37
+ }
38
+
39
+ switch (newChildren.$$typeof) {
40
+ case REACT_ELEMENT_TYPE:
41
+ {
42
+ var element = newChildren;
43
+ if (existingChild && element.type === existingChild.type && element.key === existingChild.key) {
44
+ // TODO: This is not sufficient since previous siblings could be new.
45
+ // Will fix reconciliation properly later.
46
+ var clone = shouldClone ? cloneFiber(existingChild, priority) : existingChild;
47
+ if (!shouldClone) {
48
+ // TODO: This might be lowering the priority of nested unfinished work.
49
+ clone.pendingWorkPriority = priority;
50
+ }
51
+ clone.pendingProps = element.props;
52
+ clone.sibling = null;
53
+ clone['return'] = returnFiber;
54
+ previousSibling.sibling = clone;
55
+ return clone;
56
+ }
57
+ var child = createFiberFromElement(element, priority);
58
+ previousSibling.sibling = child;
59
+ child['return'] = returnFiber;
60
+ return child;
61
+ }
62
+
63
+ case REACT_COROUTINE_TYPE:
64
+ {
65
+ var coroutine = newChildren;
66
+ var _child = createFiberFromCoroutine(coroutine, priority);
67
+ previousSibling.sibling = _child;
68
+ _child['return'] = returnFiber;
69
+ return _child;
70
+ }
71
+
72
+ case REACT_YIELD_TYPE:
73
+ {
74
+ var yieldNode = newChildren;
75
+ var reifiedYield = createReifiedYield(yieldNode);
76
+ var _child2 = createFiberFromYield(yieldNode, priority);
77
+ _child2.output = reifiedYield;
78
+ previousSibling.sibling = _child2;
79
+ _child2['return'] = returnFiber;
80
+ return _child2;
81
+ }
82
+ }
83
+
84
+ if (isArray(newChildren)) {
85
+ var prev = previousSibling;
86
+ var existing = existingChild;
87
+ for (var i = 0; i < newChildren.length; i++) {
88
+ var nextExisting = existing && existing.sibling;
89
+ prev = createSubsequentChild(returnFiber, existing, prev, newChildren[i], priority);
90
+ if (prev && existing) {
91
+ // TODO: This is not correct because there could've been more
92
+ // than one sibling consumed but I don't want to return a tuple.
93
+ existing = nextExisting;
94
+ }
95
+ }
96
+ return prev;
97
+ } else {
98
+ // TODO: Throw for unknown children.
99
+ return previousSibling;
100
+ }
101
+ }
102
+
103
+ function createFirstChild(returnFiber, existingChild, newChildren, priority) {
104
+ if (typeof newChildren !== 'object' || newChildren === null) {
105
+ return null;
106
+ }
107
+
108
+ switch (newChildren.$$typeof) {
109
+ case REACT_ELEMENT_TYPE:
110
+ {
111
+ /* $FlowFixMe(>=0.31.0): This is an unsafe cast. Consider adding a type
112
+ * annotation to the `newChildren` param of this
113
+ * function.
114
+ */
115
+ var element = newChildren;
116
+ if (existingChild && element.type === existingChild.type && element.key === existingChild.key) {
117
+ // Get the clone of the existing fiber.
118
+ var clone = shouldClone ? cloneFiber(existingChild, priority) : existingChild;
119
+ if (!shouldClone) {
120
+ // TODO: This might be lowering the priority of nested unfinished work.
121
+ clone.pendingWorkPriority = priority;
122
+ }
123
+ clone.pendingProps = element.props;
124
+ clone.sibling = null;
125
+ clone['return'] = returnFiber;
126
+ return clone;
127
+ }
128
+ var child = createFiberFromElement(element, priority);
129
+ child['return'] = returnFiber;
130
+ return child;
131
+ }
132
+
133
+ case REACT_COROUTINE_TYPE:
134
+ {
135
+ /* $FlowFixMe(>=0.31.0): No 'handler' property found in object type
136
+ */
137
+ var coroutine = newChildren;
138
+ var _child3 = createFiberFromCoroutine(coroutine, priority);
139
+ _child3['return'] = returnFiber;
140
+ return _child3;
141
+ }
142
+
143
+ case REACT_YIELD_TYPE:
144
+ {
145
+ // A yield results in a fragment fiber whose output is the continuation.
146
+ // TODO: When there is only a single child, we can optimize this to avoid
147
+ // the fragment.
148
+ /* $FlowFixMe(>=0.31.0): No 'continuation' property found in object
149
+ * type
150
+ */
151
+ var yieldNode = newChildren;
152
+ var reifiedYield = createReifiedYield(yieldNode);
153
+ var _child4 = createFiberFromYield(yieldNode, priority);
154
+ _child4.output = reifiedYield;
155
+ _child4['return'] = returnFiber;
156
+ return _child4;
157
+ }
158
+ }
159
+
160
+ if (isArray(newChildren)) {
161
+ var first = null;
162
+ var prev = null;
163
+ var existing = existingChild;
164
+ /* $FlowIssue(>=0.31.0) #12747709
165
+ *
166
+ * `Array.isArray` is matched syntactically for now until predicate
167
+ * support is complete.
168
+ */
169
+ for (var i = 0; i < newChildren.length; i++) {
170
+ var nextExisting = existing && existing.sibling;
171
+ if (prev == null) {
172
+ prev = createFirstChild(returnFiber, existing, newChildren[i], priority);
173
+ first = prev;
174
+ } else {
175
+ prev = createSubsequentChild(returnFiber, existing, prev, newChildren[i], priority);
176
+ }
177
+ if (prev && existing) {
178
+ // TODO: This is not correct because there could've been more
179
+ // than one sibling consumed but I don't want to return a tuple.
180
+ existing = nextExisting;
181
+ }
182
+ }
183
+ return first;
184
+ } else {
185
+ // TODO: Throw for unknown children.
186
+ return null;
187
+ }
188
+ }
189
+
190
+ // TODO: This API won't work because we'll need to transfer the side-effects of
191
+ // unmounting children to the returnFiber.
192
+ function reconcileChildFibers(returnFiber, currentFirstChild, newChildren, priority) {
193
+ return createFirstChild(returnFiber, currentFirstChild, newChildren, priority);
194
+ }
195
+
196
+ return reconcileChildFibers;
197
+ }
198
+
199
+ exports.reconcileChildFibers = ChildReconciler(true);
200
+
201
+ exports.reconcileChildFibersInPlace = ChildReconciler(false);
202
+
203
+ function cloneSiblings(current, workInProgress, returnFiber) {
204
+ workInProgress['return'] = returnFiber;
205
+ while (current.sibling) {
206
+ current = current.sibling;
207
+ workInProgress = workInProgress.sibling = cloneFiber(current, current.pendingWorkPriority);
208
+ workInProgress['return'] = returnFiber;
209
+ }
210
+ workInProgress.sibling = null;
211
+ }
212
+
213
+ exports.cloneChildFibers = function (current, workInProgress) {
214
+ if (!workInProgress.child) {
215
+ return;
216
+ }
217
+ if (current && workInProgress.child === current.child) {
218
+ // We use workInProgress.child since that lets Flow know that it can't be
219
+ // null since we validated that already. However, as the line above suggests
220
+ // they're actually the same thing.
221
+ var currentChild = workInProgress.child;
222
+ // TODO: This used to reset the pending priority. Not sure if that is needed.
223
+ // workInProgress.pendingWorkPriority = current.pendingWorkPriority;
224
+ // TODO: The below priority used to be set to NoWork which would've
225
+ // dropped work. This is currently unobservable but will become
226
+ // observable when the first sibling has lower priority work remaining
227
+ // than the next sibling. At that point we should add tests that catches
228
+ // this.
229
+ var newChild = cloneFiber(currentChild, currentChild.pendingWorkPriority);
230
+ workInProgress.child = newChild;
231
+ cloneSiblings(currentChild, newChild, workInProgress);
232
+ }
233
+
234
+ // If there is no alternate, then we don't need to clone the children.
235
+ // If the children of the alternate fiber is a different set, then we don't
236
+ // need to clone. We need to reset the return fiber though since we'll
237
+ // traverse down into them.
238
+ var child = workInProgress.child;
239
+ while (child) {
240
+ child['return'] = workInProgress;
241
+ child = child.sibling;
242
+ }
243
+ };
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Copyright 2014-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var ReactReconciler = require('./ReactReconciler');
14
+
15
+ var instantiateReactComponent = require('./instantiateReactComponent');
16
+ var KeyEscapeUtils = require('./KeyEscapeUtils');
17
+ var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
18
+ var traverseAllChildren = require('./traverseAllChildren');
19
+ var warning = require('fbjs/lib/warning');
20
+
21
+ var ReactComponentTreeHook;
22
+
23
+ if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
24
+ // Temporary hack.
25
+ // Inline requires don't work well with Jest:
26
+ // https://github.com/facebook/react/issues/7240
27
+ // Remove the inline requires when we don't need them anymore:
28
+ // https://github.com/facebook/react/pull/7178
29
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
30
+ }
31
+
32
+ function instantiateChild(childInstances, child, name, selfDebugID) {
33
+ // We found a component instance.
34
+ var keyUnique = childInstances[name] === undefined;
35
+ if (process.env.NODE_ENV !== 'production') {
36
+ if (!ReactComponentTreeHook) {
37
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
38
+ }
39
+ if (!keyUnique) {
40
+ process.env.NODE_ENV !== 'production' ? warning(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeHook.getStackAddendumByID(selfDebugID)) : void 0;
41
+ }
42
+ }
43
+ if (child != null && keyUnique) {
44
+ childInstances[name] = instantiateReactComponent(child, true);
45
+ }
46
+ }
47
+
48
+ /**
49
+ * ReactChildReconciler provides helpers for initializing or updating a set of
50
+ * children. Its output is suitable for passing it onto ReactMultiChild which
51
+ * does diffed reordering and insertion.
52
+ */
53
+ var ReactChildReconciler = {
54
+ /**
55
+ * Generates a "mount image" for each of the supplied children. In the case
56
+ * of `ReactDOMComponent`, a mount image is a string of markup.
57
+ *
58
+ * @param {?object} nestedChildNodes Nested child maps.
59
+ * @return {?object} A set of child instances.
60
+ * @internal
61
+ */
62
+ instantiateChildren: function (nestedChildNodes, transaction, context, selfDebugID // 0 in production and for roots
63
+ ) {
64
+ if (nestedChildNodes == null) {
65
+ return null;
66
+ }
67
+ var childInstances = {};
68
+
69
+ if (process.env.NODE_ENV !== 'production') {
70
+ traverseAllChildren(nestedChildNodes, function (childInsts, child, name) {
71
+ return instantiateChild(childInsts, child, name, selfDebugID);
72
+ }, childInstances);
73
+ } else {
74
+ traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
75
+ }
76
+ return childInstances;
77
+ },
78
+
79
+ /**
80
+ * Updates the rendered children and returns a new set of children.
81
+ *
82
+ * @param {?object} prevChildren Previously initialized set of children.
83
+ * @param {?object} nextChildren Flat child element maps.
84
+ * @param {ReactReconcileTransaction} transaction
85
+ * @param {object} context
86
+ * @return {?object} A new set of child instances.
87
+ * @internal
88
+ */
89
+ updateChildren: function (prevChildren, nextChildren, mountImages, removedNodes, transaction, hostParent, hostContainerInfo, context, selfDebugID // 0 in production and for roots
90
+ ) {
91
+ // We currently don't have a way to track moves here but if we use iterators
92
+ // instead of for..in we can zip the iterators and check if an item has
93
+ // moved.
94
+ // TODO: If nothing has changed, return the prevChildren object so that we
95
+ // can quickly bailout if nothing has changed.
96
+ if (!nextChildren && !prevChildren) {
97
+ return;
98
+ }
99
+ var name;
100
+ var prevChild;
101
+ for (name in nextChildren) {
102
+ if (!nextChildren.hasOwnProperty(name)) {
103
+ continue;
104
+ }
105
+ prevChild = prevChildren && prevChildren[name];
106
+ var prevElement = prevChild && prevChild._currentElement;
107
+ var nextElement = nextChildren[name];
108
+ if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) {
109
+ ReactReconciler.receiveComponent(prevChild, nextElement, transaction, context);
110
+ nextChildren[name] = prevChild;
111
+ } else {
112
+ if (prevChild) {
113
+ removedNodes[name] = ReactReconciler.getHostNode(prevChild);
114
+ ReactReconciler.unmountComponent(prevChild, false);
115
+ }
116
+ // The child must be instantiated before it's mounted.
117
+ var nextChildInstance = instantiateReactComponent(nextElement, true);
118
+ nextChildren[name] = nextChildInstance;
119
+ // Creating mount image now ensures refs are resolved in right order
120
+ // (see https://github.com/facebook/react/pull/7101 for explanation).
121
+ var nextChildMountImage = ReactReconciler.mountComponent(nextChildInstance, transaction, hostParent, hostContainerInfo, context, selfDebugID);
122
+ mountImages.push(nextChildMountImage);
123
+ }
124
+ }
125
+ // Unmount children that are no longer present.
126
+ for (name in prevChildren) {
127
+ if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
128
+ prevChild = prevChildren[name];
129
+ removedNodes[name] = ReactReconciler.getHostNode(prevChild);
130
+ ReactReconciler.unmountComponent(prevChild, false);
131
+ }
132
+ }
133
+ },
134
+
135
+ /**
136
+ * Unmounts all rendered children. This should be used to clean up children
137
+ * when this component is unmounted.
138
+ *
139
+ * @param {?object} renderedChildren Previously initialized set of children.
140
+ * @internal
141
+ */
142
+ unmountChildren: function (renderedChildren, safely) {
143
+ for (var name in renderedChildren) {
144
+ if (renderedChildren.hasOwnProperty(name)) {
145
+ var renderedChild = renderedChildren[name];
146
+ ReactReconciler.unmountComponent(renderedChild, safely);
147
+ }
148
+ }
149
+ }
150
+
151
+ };
152
+
153
+ module.exports = ReactChildReconciler;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var DOMChildrenOperations = require('./DOMChildrenOperations');
14
+ var ReactDOMIDOperations = require('./ReactDOMIDOperations');
15
+
16
+ /**
17
+ * Abstracts away all functionality of the reconciler that requires knowledge of
18
+ * the browser context. TODO: These callers should be refactored to avoid the
19
+ * need for this injection.
20
+ */
21
+ var ReactComponentBrowserEnvironment = {
22
+
23
+ processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
24
+
25
+ replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup
26
+
27
+ };
28
+
29
+ module.exports = ReactComponentBrowserEnvironment;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright 2014-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
16
+ var invariant = require('fbjs/lib/invariant');
17
+
18
+ var injected = false;
19
+
20
+ var ReactComponentEnvironment = {
21
+
22
+ /**
23
+ * Optionally injectable hook for swapping out mount images in the middle of
24
+ * the tree.
25
+ */
26
+ replaceNodeWithMarkup: null,
27
+
28
+ /**
29
+ * Optionally injectable hook for processing a queue of child updates. Will
30
+ * later move into MultiChildComponents.
31
+ */
32
+ processChildrenUpdates: null,
33
+
34
+ injection: {
35
+ injectEnvironment: function (environment) {
36
+ !!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : _prodInvariant('104') : void 0;
37
+ ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
38
+ ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
39
+ injected = true;
40
+ }
41
+ }
42
+
43
+ };
44
+
45
+ module.exports = ReactComponentEnvironment;