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,901 @@
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 _prodInvariant = require('./reactProdInvariant'),
14
+ _assign = require('object-assign');
15
+
16
+ var React = require('react/lib/React');
17
+ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
18
+ var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
19
+ var ReactErrorUtils = require('./ReactErrorUtils');
20
+ var ReactInstanceMap = require('./ReactInstanceMap');
21
+ var ReactInstrumentation = require('./ReactInstrumentation');
22
+ var ReactNodeTypes = require('./ReactNodeTypes');
23
+ var ReactReconciler = require('./ReactReconciler');
24
+
25
+ if (process.env.NODE_ENV !== 'production') {
26
+ var checkReactTypeSpec = require('./checkReactTypeSpec');
27
+ }
28
+
29
+ var emptyObject = require('fbjs/lib/emptyObject');
30
+ var invariant = require('fbjs/lib/invariant');
31
+ var shallowEqual = require('fbjs/lib/shallowEqual');
32
+ var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
33
+ var warning = require('fbjs/lib/warning');
34
+
35
+ var CompositeTypes = {
36
+ ImpureClass: 0,
37
+ PureClass: 1,
38
+ StatelessFunctional: 2
39
+ };
40
+
41
+ function StatelessComponent(Component) {}
42
+ StatelessComponent.prototype.render = function () {
43
+ var Component = ReactInstanceMap.get(this)._currentElement.type;
44
+ var element = Component(this.props, this.context, this.updater);
45
+ warnIfInvalidElement(Component, element);
46
+ return element;
47
+ };
48
+
49
+ function warnIfInvalidElement(Component, element) {
50
+ if (process.env.NODE_ENV !== 'production') {
51
+ process.env.NODE_ENV !== 'production' ? warning(element === null || element === false || React.isValidElement(element), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : void 0;
52
+ process.env.NODE_ENV !== 'production' ? warning(!Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component') : void 0;
53
+ }
54
+ }
55
+
56
+ function shouldConstruct(Component) {
57
+ return !!(Component.prototype && Component.prototype.isReactComponent);
58
+ }
59
+
60
+ function isPureComponent(Component) {
61
+ return !!(Component.prototype && Component.prototype.isPureReactComponent);
62
+ }
63
+
64
+ // Separated into a function to contain deoptimizations caused by try/finally.
65
+ function measureLifeCyclePerf(fn, debugID, timerType) {
66
+ if (debugID === 0) {
67
+ // Top-level wrappers (see ReactMount) and empty components (see
68
+ // ReactDOMEmptyComponent) are invisible to hooks and devtools.
69
+ // Both are implementation details that should go away in the future.
70
+ return fn();
71
+ }
72
+
73
+ ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID, timerType);
74
+ try {
75
+ return fn();
76
+ } finally {
77
+ ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID, timerType);
78
+ }
79
+ }
80
+
81
+ /**
82
+ * ------------------ The Life-Cycle of a Composite Component ------------------
83
+ *
84
+ * - constructor: Initialization of state. The instance is now retained.
85
+ * - componentWillMount
86
+ * - render
87
+ * - [children's constructors]
88
+ * - [children's componentWillMount and render]
89
+ * - [children's componentDidMount]
90
+ * - componentDidMount
91
+ *
92
+ * Update Phases:
93
+ * - componentWillReceiveProps (only called if parent updated)
94
+ * - shouldComponentUpdate
95
+ * - componentWillUpdate
96
+ * - render
97
+ * - [children's constructors or receive props phases]
98
+ * - componentDidUpdate
99
+ *
100
+ * - componentWillUnmount
101
+ * - [children's componentWillUnmount]
102
+ * - [children destroyed]
103
+ * - (destroyed): The instance is now blank, released by React and ready for GC.
104
+ *
105
+ * -----------------------------------------------------------------------------
106
+ */
107
+
108
+ /**
109
+ * An incrementing ID assigned to each component when it is mounted. This is
110
+ * used to enforce the order in which `ReactUpdates` updates dirty components.
111
+ *
112
+ * @private
113
+ */
114
+ var nextMountID = 1;
115
+
116
+ /**
117
+ * @lends {ReactCompositeComponent.prototype}
118
+ */
119
+ var ReactCompositeComponent = {
120
+
121
+ /**
122
+ * Base constructor for all composite component.
123
+ *
124
+ * @param {ReactElement} element
125
+ * @final
126
+ * @internal
127
+ */
128
+ construct: function (element) {
129
+ this._currentElement = element;
130
+ this._rootNodeID = 0;
131
+ this._compositeType = null;
132
+ this._instance = null;
133
+ this._hostParent = null;
134
+ this._hostContainerInfo = null;
135
+
136
+ // See ReactUpdateQueue
137
+ this._updateBatchNumber = null;
138
+ this._pendingElement = null;
139
+ this._pendingStateQueue = null;
140
+ this._pendingReplaceState = false;
141
+ this._pendingForceUpdate = false;
142
+
143
+ this._renderedNodeType = null;
144
+ this._renderedComponent = null;
145
+ this._context = null;
146
+ this._mountOrder = 0;
147
+ this._topLevelWrapper = null;
148
+
149
+ // See ReactUpdates and ReactUpdateQueue.
150
+ this._pendingCallbacks = null;
151
+
152
+ // ComponentWillUnmount shall only be called once
153
+ this._calledComponentWillUnmount = false;
154
+
155
+ if (process.env.NODE_ENV !== 'production') {
156
+ this._warnedAboutRefsInRender = false;
157
+ }
158
+ },
159
+
160
+ /**
161
+ * Initializes the component, renders markup, and registers event listeners.
162
+ *
163
+ * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
164
+ * @param {?object} hostParent
165
+ * @param {?object} hostContainerInfo
166
+ * @param {?object} context
167
+ * @return {?string} Rendered markup to be inserted into the DOM.
168
+ * @final
169
+ * @internal
170
+ */
171
+ mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
172
+ var _this = this;
173
+
174
+ this._context = context;
175
+ this._mountOrder = nextMountID++;
176
+ this._hostParent = hostParent;
177
+ this._hostContainerInfo = hostContainerInfo;
178
+
179
+ var publicProps = this._currentElement.props;
180
+ var publicContext = this._processContext(context);
181
+
182
+ var Component = this._currentElement.type;
183
+
184
+ var updateQueue = transaction.getUpdateQueue();
185
+
186
+ // Initialize the public class
187
+ var doConstruct = shouldConstruct(Component);
188
+ var inst = this._constructComponent(doConstruct, publicProps, publicContext, updateQueue);
189
+ var renderedElement;
190
+
191
+ // Support functional components
192
+ if (!doConstruct && (inst == null || inst.render == null)) {
193
+ renderedElement = inst;
194
+ warnIfInvalidElement(Component, renderedElement);
195
+ !(inst === null || inst === false || React.isValidElement(inst)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : _prodInvariant('105', Component.displayName || Component.name || 'Component') : void 0;
196
+ inst = new StatelessComponent(Component);
197
+ this._compositeType = CompositeTypes.StatelessFunctional;
198
+ } else {
199
+ if (isPureComponent(Component)) {
200
+ this._compositeType = CompositeTypes.PureClass;
201
+ } else {
202
+ this._compositeType = CompositeTypes.ImpureClass;
203
+ }
204
+ }
205
+
206
+ if (process.env.NODE_ENV !== 'production') {
207
+ // This will throw later in _renderValidatedComponent, but add an early
208
+ // warning now to help debugging
209
+ if (inst.render == null) {
210
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', Component.displayName || Component.name || 'Component') : void 0;
211
+ }
212
+
213
+ var propsMutated = inst.props !== publicProps;
214
+ var componentName = Component.displayName || Component.name || 'Component';
215
+
216
+ process.env.NODE_ENV !== 'production' ? warning(inst.props === undefined || !propsMutated, '%s(...): When calling super() in `%s`, make sure to pass ' + 'up the same props that your component\'s constructor was passed.', componentName, componentName) : void 0;
217
+ }
218
+
219
+ // These should be set up in the constructor, but as a convenience for
220
+ // simpler class abstractions, we set them up after the fact.
221
+ inst.props = publicProps;
222
+ inst.context = publicContext;
223
+ inst.refs = emptyObject;
224
+ inst.updater = updateQueue;
225
+
226
+ this._instance = inst;
227
+
228
+ // Store a reference from the instance back to the internal representation
229
+ ReactInstanceMap.set(inst, this);
230
+
231
+ if (process.env.NODE_ENV !== 'production') {
232
+ // Since plain JS classes are defined without any special initialization
233
+ // logic, we can not catch common errors early. Therefore, we have to
234
+ // catch them here, at initialization time, instead.
235
+ process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved || inst.state, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : void 0;
236
+ process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : void 0;
237
+ process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : void 0;
238
+ process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : void 0;
239
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', this.getName() || 'A component') : void 0;
240
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') : void 0;
241
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : void 0;
242
+ }
243
+
244
+ var initialState = inst.state;
245
+ if (initialState === undefined) {
246
+ inst.state = initialState = null;
247
+ }
248
+ !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : _prodInvariant('106', this.getName() || 'ReactCompositeComponent') : void 0;
249
+
250
+ this._pendingStateQueue = null;
251
+ this._pendingReplaceState = false;
252
+ this._pendingForceUpdate = false;
253
+
254
+ var markup;
255
+ if (inst.unstable_handleError) {
256
+ markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context);
257
+ } else {
258
+ markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
259
+ }
260
+
261
+ if (inst.componentDidMount) {
262
+ if (process.env.NODE_ENV !== 'production') {
263
+ transaction.getReactMountReady().enqueue(function () {
264
+ measureLifeCyclePerf(function () {
265
+ return inst.componentDidMount();
266
+ }, _this._debugID, 'componentDidMount');
267
+ });
268
+ } else {
269
+ transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
270
+ }
271
+ }
272
+
273
+ return markup;
274
+ },
275
+
276
+ _constructComponent: function (doConstruct, publicProps, publicContext, updateQueue) {
277
+ if (process.env.NODE_ENV !== 'production') {
278
+ ReactCurrentOwner.current = this;
279
+ try {
280
+ return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
281
+ } finally {
282
+ ReactCurrentOwner.current = null;
283
+ }
284
+ } else {
285
+ return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
286
+ }
287
+ },
288
+
289
+ _constructComponentWithoutOwner: function (doConstruct, publicProps, publicContext, updateQueue) {
290
+ var Component = this._currentElement.type;
291
+
292
+ if (doConstruct) {
293
+ if (process.env.NODE_ENV !== 'production') {
294
+ return measureLifeCyclePerf(function () {
295
+ return new Component(publicProps, publicContext, updateQueue);
296
+ }, this._debugID, 'ctor');
297
+ } else {
298
+ return new Component(publicProps, publicContext, updateQueue);
299
+ }
300
+ }
301
+
302
+ // This can still be an instance in case of factory components
303
+ // but we'll count this as time spent rendering as the more common case.
304
+ if (process.env.NODE_ENV !== 'production') {
305
+ return measureLifeCyclePerf(function () {
306
+ return Component(publicProps, publicContext, updateQueue);
307
+ }, this._debugID, 'render');
308
+ } else {
309
+ return Component(publicProps, publicContext, updateQueue);
310
+ }
311
+ },
312
+
313
+ performInitialMountWithErrorHandling: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
314
+ var markup;
315
+ var checkpoint = transaction.checkpoint();
316
+ try {
317
+ markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
318
+ } catch (e) {
319
+ // Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
320
+ transaction.rollback(checkpoint);
321
+ this._instance.unstable_handleError(e);
322
+ if (this._pendingStateQueue) {
323
+ this._instance.state = this._processPendingState(this._instance.props, this._instance.context);
324
+ }
325
+ checkpoint = transaction.checkpoint();
326
+
327
+ this._renderedComponent.unmountComponent(true);
328
+ transaction.rollback(checkpoint);
329
+
330
+ // Try again - we've informed the component about the error, so they can render an error message this time.
331
+ // If this throws again, the error will bubble up (and can be caught by a higher error boundary).
332
+ markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
333
+ }
334
+ return markup;
335
+ },
336
+
337
+ performInitialMount: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
338
+ var inst = this._instance;
339
+
340
+ var debugID = 0;
341
+ if (process.env.NODE_ENV !== 'production') {
342
+ debugID = this._debugID;
343
+ }
344
+
345
+ if (inst.componentWillMount) {
346
+ if (process.env.NODE_ENV !== 'production') {
347
+ measureLifeCyclePerf(function () {
348
+ return inst.componentWillMount();
349
+ }, debugID, 'componentWillMount');
350
+ } else {
351
+ inst.componentWillMount();
352
+ }
353
+ // When mounting, calls to `setState` by `componentWillMount` will set
354
+ // `this._pendingStateQueue` without triggering a re-render.
355
+ if (this._pendingStateQueue) {
356
+ inst.state = this._processPendingState(inst.props, inst.context);
357
+ }
358
+ }
359
+
360
+ // If not a stateless component, we now render
361
+ if (renderedElement === undefined) {
362
+ renderedElement = this._renderValidatedComponent();
363
+ }
364
+
365
+ var nodeType = ReactNodeTypes.getType(renderedElement);
366
+ this._renderedNodeType = nodeType;
367
+ var child = this._instantiateReactComponent(renderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */
368
+ );
369
+ this._renderedComponent = child;
370
+
371
+ var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID);
372
+
373
+ if (process.env.NODE_ENV !== 'production') {
374
+ if (debugID !== 0) {
375
+ var childDebugIDs = child._debugID !== 0 ? [child._debugID] : [];
376
+ ReactInstrumentation.debugTool.onSetChildren(debugID, childDebugIDs);
377
+ }
378
+ }
379
+
380
+ return markup;
381
+ },
382
+
383
+ getHostNode: function () {
384
+ return ReactReconciler.getHostNode(this._renderedComponent);
385
+ },
386
+
387
+ /**
388
+ * Releases any resources allocated by `mountComponent`.
389
+ *
390
+ * @final
391
+ * @internal
392
+ */
393
+ unmountComponent: function (safely) {
394
+ if (!this._renderedComponent) {
395
+ return;
396
+ }
397
+
398
+ var inst = this._instance;
399
+
400
+ if (inst.componentWillUnmount && !inst._calledComponentWillUnmount) {
401
+ inst._calledComponentWillUnmount = true;
402
+
403
+ if (safely) {
404
+ var name = this.getName() + '.componentWillUnmount()';
405
+ ReactErrorUtils.invokeGuardedCallback(name, inst.componentWillUnmount.bind(inst));
406
+ } else {
407
+ if (process.env.NODE_ENV !== 'production') {
408
+ measureLifeCyclePerf(function () {
409
+ return inst.componentWillUnmount();
410
+ }, this._debugID, 'componentWillUnmount');
411
+ } else {
412
+ inst.componentWillUnmount();
413
+ }
414
+ }
415
+ }
416
+
417
+ if (this._renderedComponent) {
418
+ ReactReconciler.unmountComponent(this._renderedComponent, safely);
419
+ this._renderedNodeType = null;
420
+ this._renderedComponent = null;
421
+ this._instance = null;
422
+ }
423
+
424
+ // Reset pending fields
425
+ // Even if this component is scheduled for another update in ReactUpdates,
426
+ // it would still be ignored because these fields are reset.
427
+ this._pendingStateQueue = null;
428
+ this._pendingReplaceState = false;
429
+ this._pendingForceUpdate = false;
430
+ this._pendingCallbacks = null;
431
+ this._pendingElement = null;
432
+
433
+ // These fields do not really need to be reset since this object is no
434
+ // longer accessible.
435
+ this._context = null;
436
+ this._rootNodeID = 0;
437
+ this._topLevelWrapper = null;
438
+
439
+ // Delete the reference from the instance to this internal representation
440
+ // which allow the internals to be properly cleaned up even if the user
441
+ // leaks a reference to the public instance.
442
+ ReactInstanceMap.remove(inst);
443
+
444
+ // Some existing components rely on inst.props even after they've been
445
+ // destroyed (in event handlers).
446
+ // TODO: inst.props = null;
447
+ // TODO: inst.state = null;
448
+ // TODO: inst.context = null;
449
+ },
450
+
451
+ /**
452
+ * Filters the context object to only contain keys specified in
453
+ * `contextTypes`
454
+ *
455
+ * @param {object} context
456
+ * @return {?object}
457
+ * @private
458
+ */
459
+ _maskContext: function (context) {
460
+ var Component = this._currentElement.type;
461
+ var contextTypes = Component.contextTypes;
462
+ if (!contextTypes) {
463
+ return emptyObject;
464
+ }
465
+ var maskedContext = {};
466
+ for (var contextName in contextTypes) {
467
+ maskedContext[contextName] = context[contextName];
468
+ }
469
+ return maskedContext;
470
+ },
471
+
472
+ /**
473
+ * Filters the context object to only contain keys specified in
474
+ * `contextTypes`, and asserts that they are valid.
475
+ *
476
+ * @param {object} context
477
+ * @return {?object}
478
+ * @private
479
+ */
480
+ _processContext: function (context) {
481
+ var maskedContext = this._maskContext(context);
482
+ if (process.env.NODE_ENV !== 'production') {
483
+ var Component = this._currentElement.type;
484
+ if (Component.contextTypes) {
485
+ this._checkContextTypes(Component.contextTypes, maskedContext, 'context');
486
+ }
487
+ }
488
+ return maskedContext;
489
+ },
490
+
491
+ /**
492
+ * @param {object} currentContext
493
+ * @return {object}
494
+ * @private
495
+ */
496
+ _processChildContext: function (currentContext) {
497
+ var Component = this._currentElement.type;
498
+ var inst = this._instance;
499
+ var childContext;
500
+
501
+ if (inst.getChildContext) {
502
+ if (process.env.NODE_ENV !== 'production') {
503
+ ReactInstrumentation.debugTool.onBeginProcessingChildContext();
504
+ try {
505
+ childContext = inst.getChildContext();
506
+ } finally {
507
+ ReactInstrumentation.debugTool.onEndProcessingChildContext();
508
+ }
509
+ } else {
510
+ childContext = inst.getChildContext();
511
+ }
512
+ }
513
+
514
+ if (childContext) {
515
+ !(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().', this.getName() || 'ReactCompositeComponent') : _prodInvariant('107', this.getName() || 'ReactCompositeComponent') : void 0;
516
+ if (process.env.NODE_ENV !== 'production') {
517
+ this._checkContextTypes(Component.childContextTypes, childContext, 'child context');
518
+ }
519
+ for (var name in childContext) {
520
+ !(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : _prodInvariant('108', this.getName() || 'ReactCompositeComponent', name) : void 0;
521
+ }
522
+ return _assign({}, currentContext, childContext);
523
+ }
524
+ return currentContext;
525
+ },
526
+
527
+ /**
528
+ * Assert that the context types are valid
529
+ *
530
+ * @param {object} typeSpecs Map of context field to a ReactPropType
531
+ * @param {object} values Runtime values that need to be type-checked
532
+ * @param {string} location e.g. "prop", "context", "child context"
533
+ * @private
534
+ */
535
+ _checkContextTypes: function (typeSpecs, values, location) {
536
+ if (process.env.NODE_ENV !== 'production') {
537
+ checkReactTypeSpec(typeSpecs, values, location, this.getName(), null, this._debugID);
538
+ }
539
+ },
540
+
541
+ receiveComponent: function (nextElement, transaction, nextContext) {
542
+ var prevElement = this._currentElement;
543
+ var prevContext = this._context;
544
+
545
+ this._pendingElement = null;
546
+
547
+ this.updateComponent(transaction, prevElement, nextElement, prevContext, nextContext);
548
+ },
549
+
550
+ /**
551
+ * If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
552
+ * is set, update the component.
553
+ *
554
+ * @param {ReactReconcileTransaction} transaction
555
+ * @internal
556
+ */
557
+ performUpdateIfNecessary: function (transaction) {
558
+ if (this._pendingElement != null) {
559
+ ReactReconciler.receiveComponent(this, this._pendingElement, transaction, this._context);
560
+ } else if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
561
+ this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
562
+ } else {
563
+ this._updateBatchNumber = null;
564
+ }
565
+ },
566
+
567
+ /**
568
+ * Perform an update to a mounted component. The componentWillReceiveProps and
569
+ * shouldComponentUpdate methods are called, then (assuming the update isn't
570
+ * skipped) the remaining update lifecycle methods are called and the DOM
571
+ * representation is updated.
572
+ *
573
+ * By default, this implements React's rendering and reconciliation algorithm.
574
+ * Sophisticated clients may wish to override this.
575
+ *
576
+ * @param {ReactReconcileTransaction} transaction
577
+ * @param {ReactElement} prevParentElement
578
+ * @param {ReactElement} nextParentElement
579
+ * @internal
580
+ * @overridable
581
+ */
582
+ updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
583
+ var inst = this._instance;
584
+ !(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Attempted to update component `%s` that has already been unmounted (or failed to mount).', this.getName() || 'ReactCompositeComponent') : _prodInvariant('136', this.getName() || 'ReactCompositeComponent') : void 0;
585
+
586
+ var willReceive = false;
587
+ var nextContext;
588
+
589
+ // Determine if the context has changed or not
590
+ if (this._context === nextUnmaskedContext) {
591
+ nextContext = inst.context;
592
+ } else {
593
+ nextContext = this._processContext(nextUnmaskedContext);
594
+ willReceive = true;
595
+ }
596
+
597
+ var prevProps = prevParentElement.props;
598
+ var nextProps = nextParentElement.props;
599
+
600
+ // Not a simple state update but a props update
601
+ if (prevParentElement !== nextParentElement) {
602
+ willReceive = true;
603
+ }
604
+
605
+ // An update here will schedule an update but immediately set
606
+ // _pendingStateQueue which will ensure that any state updates gets
607
+ // immediately reconciled instead of waiting for the next batch.
608
+ if (willReceive && inst.componentWillReceiveProps) {
609
+ if (process.env.NODE_ENV !== 'production') {
610
+ measureLifeCyclePerf(function () {
611
+ return inst.componentWillReceiveProps(nextProps, nextContext);
612
+ }, this._debugID, 'componentWillReceiveProps');
613
+ } else {
614
+ inst.componentWillReceiveProps(nextProps, nextContext);
615
+ }
616
+ }
617
+
618
+ var nextState = this._processPendingState(nextProps, nextContext);
619
+ var shouldUpdate = true;
620
+
621
+ if (!this._pendingForceUpdate) {
622
+ if (inst.shouldComponentUpdate) {
623
+ if (process.env.NODE_ENV !== 'production') {
624
+ shouldUpdate = measureLifeCyclePerf(function () {
625
+ return inst.shouldComponentUpdate(nextProps, nextState, nextContext);
626
+ }, this._debugID, 'shouldComponentUpdate');
627
+ } else {
628
+ shouldUpdate = inst.shouldComponentUpdate(nextProps, nextState, nextContext);
629
+ }
630
+ } else {
631
+ if (this._compositeType === CompositeTypes.PureClass) {
632
+ shouldUpdate = !shallowEqual(prevProps, nextProps) || !shallowEqual(inst.state, nextState);
633
+ }
634
+ }
635
+ }
636
+
637
+ if (process.env.NODE_ENV !== 'production') {
638
+ process.env.NODE_ENV !== 'production' ? warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : void 0;
639
+ }
640
+
641
+ this._updateBatchNumber = null;
642
+ if (shouldUpdate) {
643
+ this._pendingForceUpdate = false;
644
+ // Will set `this.props`, `this.state` and `this.context`.
645
+ this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext);
646
+ } else {
647
+ // If it's determined that a component should not update, we still want
648
+ // to set props and state but we shortcut the rest of the update.
649
+ this._currentElement = nextParentElement;
650
+ this._context = nextUnmaskedContext;
651
+ inst.props = nextProps;
652
+ inst.state = nextState;
653
+ inst.context = nextContext;
654
+ }
655
+ },
656
+
657
+ _processPendingState: function (props, context) {
658
+ var inst = this._instance;
659
+ var queue = this._pendingStateQueue;
660
+ var replace = this._pendingReplaceState;
661
+ this._pendingReplaceState = false;
662
+ this._pendingStateQueue = null;
663
+
664
+ if (!queue) {
665
+ return inst.state;
666
+ }
667
+
668
+ if (replace && queue.length === 1) {
669
+ return queue[0];
670
+ }
671
+
672
+ var nextState = _assign({}, replace ? queue[0] : inst.state);
673
+ for (var i = replace ? 1 : 0; i < queue.length; i++) {
674
+ var partial = queue[i];
675
+ _assign(nextState, typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial);
676
+ }
677
+
678
+ return nextState;
679
+ },
680
+
681
+ /**
682
+ * Merges new props and state, notifies delegate methods of update and
683
+ * performs update.
684
+ *
685
+ * @param {ReactElement} nextElement Next element
686
+ * @param {object} nextProps Next public object to set as properties.
687
+ * @param {?object} nextState Next object to set as state.
688
+ * @param {?object} nextContext Next public object to set as context.
689
+ * @param {ReactReconcileTransaction} transaction
690
+ * @param {?object} unmaskedContext
691
+ * @private
692
+ */
693
+ _performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
694
+ var _this2 = this;
695
+
696
+ var inst = this._instance;
697
+
698
+ var hasComponentDidUpdate = Boolean(inst.componentDidUpdate);
699
+ var prevProps;
700
+ var prevState;
701
+ var prevContext;
702
+ if (hasComponentDidUpdate) {
703
+ prevProps = inst.props;
704
+ prevState = inst.state;
705
+ prevContext = inst.context;
706
+ }
707
+
708
+ if (inst.componentWillUpdate) {
709
+ if (process.env.NODE_ENV !== 'production') {
710
+ measureLifeCyclePerf(function () {
711
+ return inst.componentWillUpdate(nextProps, nextState, nextContext);
712
+ }, this._debugID, 'componentWillUpdate');
713
+ } else {
714
+ inst.componentWillUpdate(nextProps, nextState, nextContext);
715
+ }
716
+ }
717
+
718
+ this._currentElement = nextElement;
719
+ this._context = unmaskedContext;
720
+ inst.props = nextProps;
721
+ inst.state = nextState;
722
+ inst.context = nextContext;
723
+
724
+ this._updateRenderedComponent(transaction, unmaskedContext);
725
+
726
+ if (hasComponentDidUpdate) {
727
+ if (process.env.NODE_ENV !== 'production') {
728
+ transaction.getReactMountReady().enqueue(function () {
729
+ measureLifeCyclePerf(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), _this2._debugID, 'componentDidUpdate');
730
+ });
731
+ } else {
732
+ transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
733
+ }
734
+ }
735
+ },
736
+
737
+ /**
738
+ * Call the component's `render` method and update the DOM accordingly.
739
+ *
740
+ * @param {ReactReconcileTransaction} transaction
741
+ * @internal
742
+ */
743
+ _updateRenderedComponent: function (transaction, context) {
744
+ var prevComponentInstance = this._renderedComponent;
745
+ var prevRenderedElement = prevComponentInstance._currentElement;
746
+ var nextRenderedElement = this._renderValidatedComponent();
747
+
748
+ var debugID = 0;
749
+ if (process.env.NODE_ENV !== 'production') {
750
+ debugID = this._debugID;
751
+ }
752
+
753
+ if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
754
+ ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
755
+ } else {
756
+ var oldHostNode = ReactReconciler.getHostNode(prevComponentInstance);
757
+ ReactReconciler.unmountComponent(prevComponentInstance, false);
758
+
759
+ var nodeType = ReactNodeTypes.getType(nextRenderedElement);
760
+ this._renderedNodeType = nodeType;
761
+ var child = this._instantiateReactComponent(nextRenderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */
762
+ );
763
+ this._renderedComponent = child;
764
+
765
+ var nextMarkup = ReactReconciler.mountComponent(child, transaction, this._hostParent, this._hostContainerInfo, this._processChildContext(context), debugID);
766
+
767
+ if (process.env.NODE_ENV !== 'production') {
768
+ if (debugID !== 0) {
769
+ var childDebugIDs = child._debugID !== 0 ? [child._debugID] : [];
770
+ ReactInstrumentation.debugTool.onSetChildren(debugID, childDebugIDs);
771
+ }
772
+ }
773
+
774
+ this._replaceNodeWithMarkup(oldHostNode, nextMarkup, prevComponentInstance);
775
+ }
776
+ },
777
+
778
+ /**
779
+ * Overridden in shallow rendering.
780
+ *
781
+ * @protected
782
+ */
783
+ _replaceNodeWithMarkup: function (oldHostNode, nextMarkup, prevInstance) {
784
+ ReactComponentEnvironment.replaceNodeWithMarkup(oldHostNode, nextMarkup, prevInstance);
785
+ },
786
+
787
+ /**
788
+ * @protected
789
+ */
790
+ _renderValidatedComponentWithoutOwnerOrContext: function () {
791
+ var inst = this._instance;
792
+ var renderedElement;
793
+
794
+ if (process.env.NODE_ENV !== 'production') {
795
+ renderedElement = measureLifeCyclePerf(function () {
796
+ return inst.render();
797
+ }, this._debugID, 'render');
798
+ } else {
799
+ renderedElement = inst.render();
800
+ }
801
+
802
+ if (process.env.NODE_ENV !== 'production') {
803
+ // We allow auto-mocks to proceed as if they're returning null.
804
+ if (renderedElement === undefined && inst.render._isMockFunction) {
805
+ // This is probably bad practice. Consider warning here and
806
+ // deprecating this convenience.
807
+ renderedElement = null;
808
+ }
809
+ }
810
+
811
+ return renderedElement;
812
+ },
813
+
814
+ /**
815
+ * @private
816
+ */
817
+ _renderValidatedComponent: function () {
818
+ var renderedElement;
819
+ if (process.env.NODE_ENV !== 'production' || this._compositeType !== CompositeTypes.StatelessFunctional) {
820
+ ReactCurrentOwner.current = this;
821
+ try {
822
+ renderedElement = this._renderValidatedComponentWithoutOwnerOrContext();
823
+ } finally {
824
+ ReactCurrentOwner.current = null;
825
+ }
826
+ } else {
827
+ renderedElement = this._renderValidatedComponentWithoutOwnerOrContext();
828
+ }
829
+ !(
830
+ // TODO: An `isValidNode` function would probably be more appropriate
831
+ renderedElement === null || renderedElement === false || React.isValidElement(renderedElement)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : _prodInvariant('109', this.getName() || 'ReactCompositeComponent') : void 0;
832
+
833
+ return renderedElement;
834
+ },
835
+
836
+ /**
837
+ * Lazily allocates the refs object and stores `component` as `ref`.
838
+ *
839
+ * @param {string} ref Reference name.
840
+ * @param {component} component Component to store as `ref`.
841
+ * @final
842
+ * @private
843
+ */
844
+ attachRef: function (ref, component) {
845
+ var inst = this.getPublicInstance();
846
+ !(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : _prodInvariant('110') : void 0;
847
+ var publicComponentInstance = component.getPublicInstance();
848
+ if (process.env.NODE_ENV !== 'production') {
849
+ var componentName = component && component.getName ? component.getName() : 'a component';
850
+ process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null || component._compositeType !== CompositeTypes.StatelessFunctional, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : void 0;
851
+ }
852
+ var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
853
+ refs[ref] = publicComponentInstance;
854
+ },
855
+
856
+ /**
857
+ * Detaches a reference name.
858
+ *
859
+ * @param {string} ref Name to dereference.
860
+ * @final
861
+ * @private
862
+ */
863
+ detachRef: function (ref) {
864
+ var refs = this.getPublicInstance().refs;
865
+ delete refs[ref];
866
+ },
867
+
868
+ /**
869
+ * Get a text description of the component that can be used to identify it
870
+ * in error messages.
871
+ * @return {string} The name or null.
872
+ * @internal
873
+ */
874
+ getName: function () {
875
+ var type = this._currentElement.type;
876
+ var constructor = this._instance && this._instance.constructor;
877
+ return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
878
+ },
879
+
880
+ /**
881
+ * Get the publicly accessible representation of this component - i.e. what
882
+ * is exposed by refs and returned by render. Can be null for stateless
883
+ * components.
884
+ *
885
+ * @return {ReactComponent} the public component instance.
886
+ * @internal
887
+ */
888
+ getPublicInstance: function () {
889
+ var inst = this._instance;
890
+ if (this._compositeType === CompositeTypes.StatelessFunctional) {
891
+ return null;
892
+ }
893
+ return inst;
894
+ },
895
+
896
+ // Stub
897
+ _instantiateReactComponent: null
898
+
899
+ };
900
+
901
+ module.exports = ReactCompositeComponent;