react 0.14.0-beta1 → 0.14.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 (173) hide show
  1. package/addons.js +8 -3
  2. package/dist/react-with-addons.js +5048 -4095
  3. package/dist/react-with-addons.min.js +6 -6
  4. package/dist/react.js +4555 -3729
  5. package/dist/react.min.js +6 -5
  6. package/lib/AutoFocusUtils.js +3 -3
  7. package/lib/BeforeInputEventPlugin.js +13 -13
  8. package/lib/CSSProperty.js +18 -3
  9. package/lib/CSSPropertyOperations.js +27 -14
  10. package/lib/CallbackQueue.js +4 -4
  11. package/lib/ChangeEventPlugin.js +15 -14
  12. package/lib/DOMChildrenOperations.js +22 -7
  13. package/lib/DOMProperty.js +8 -8
  14. package/lib/DOMPropertyOperations.js +23 -10
  15. package/lib/Danger.js +21 -16
  16. package/lib/DefaultEventPluginOrder.js +2 -2
  17. package/lib/EnterLeaveEventPlugin.js +18 -10
  18. package/lib/EventConstants.js +23 -1
  19. package/lib/EventPluginHub.js +29 -21
  20. package/lib/EventPluginRegistry.js +8 -8
  21. package/lib/EventPluginUtils.js +34 -38
  22. package/lib/EventPropagators.js +8 -8
  23. package/lib/FallbackCompositionState.js +9 -3
  24. package/lib/HTMLDOMPropertyConfig.js +24 -4
  25. package/lib/LinkedStateMixin.js +2 -2
  26. package/lib/LinkedValueUtils.js +8 -8
  27. package/lib/MetaMatchers.js +118 -0
  28. package/lib/OrderedMap.js +453 -0
  29. package/lib/PooledClass.js +3 -5
  30. package/lib/React.js +18 -7
  31. package/lib/ReactBrowserComponentMixin.js +4 -4
  32. package/lib/ReactBrowserEventEmitter.js +36 -7
  33. package/lib/ReactCSSTransitionGroup.js +35 -9
  34. package/lib/ReactCSSTransitionGroupChild.js +48 -30
  35. package/lib/ReactChildReconciler.js +24 -19
  36. package/lib/ReactChildren.js +72 -32
  37. package/lib/ReactClass.js +46 -46
  38. package/lib/ReactComponent.js +18 -16
  39. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  40. package/lib/ReactComponentEnvironment.js +2 -2
  41. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  42. package/lib/ReactCompositeComponent.js +95 -44
  43. package/lib/ReactDOM.js +74 -159
  44. package/lib/ReactDOMComponent.js +235 -93
  45. package/lib/ReactDOMFactories.js +177 -0
  46. package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
  47. package/lib/ReactDOMIDOperations.js +8 -81
  48. package/lib/ReactDOMInput.js +18 -9
  49. package/lib/ReactDOMOption.js +7 -7
  50. package/lib/ReactDOMSelect.js +9 -9
  51. package/lib/ReactDOMSelection.js +19 -3
  52. package/lib/ReactDOMServer.js +5 -3
  53. package/lib/ReactDOMTextComponent.js +33 -20
  54. package/lib/ReactDOMTextarea.js +14 -12
  55. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  56. package/lib/ReactDefaultInjection.js +23 -25
  57. package/lib/ReactDefaultPerf.js +17 -11
  58. package/lib/ReactDefaultPerfAnalysis.js +13 -12
  59. package/lib/ReactElement.js +85 -39
  60. package/lib/ReactElementValidator.js +47 -90
  61. package/lib/ReactEmptyComponent.js +26 -62
  62. package/lib/ReactEmptyComponentRegistry.js +48 -0
  63. package/lib/ReactErrorUtils.js +53 -9
  64. package/lib/ReactEventEmitterMixin.js +2 -2
  65. package/lib/ReactEventListener.js +33 -21
  66. package/lib/ReactFragment.js +27 -118
  67. package/lib/ReactInjection.js +10 -12
  68. package/lib/ReactInputSelection.js +4 -4
  69. package/lib/ReactInstanceHandles.js +10 -11
  70. package/lib/ReactIsomorphic.js +15 -11
  71. package/lib/ReactLink.js +2 -2
  72. package/lib/ReactMarkupChecksum.js +6 -2
  73. package/lib/ReactMount.js +186 -85
  74. package/lib/ReactMultiChild.js +119 -25
  75. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  76. package/lib/ReactNativeComponent.js +3 -3
  77. package/lib/ReactNoopUpdateQueue.js +3 -3
  78. package/lib/ReactOwner.js +3 -3
  79. package/lib/ReactPerf.js +2 -2
  80. package/lib/ReactPropTransferer.js +3 -3
  81. package/lib/ReactPropTypeLocationNames.js +1 -1
  82. package/lib/ReactPropTypeLocations.js +1 -1
  83. package/lib/ReactPropTypes.js +38 -9
  84. package/lib/ReactReconcileTransaction.js +10 -8
  85. package/lib/ReactReconciler.js +5 -6
  86. package/lib/ReactRef.js +14 -2
  87. package/lib/ReactServerBatchingStrategy.js +5 -5
  88. package/lib/ReactServerRendering.js +12 -12
  89. package/lib/ReactServerRenderingTransaction.js +6 -5
  90. package/lib/ReactTestUtils.js +47 -39
  91. package/lib/ReactTransitionChildMapping.js +3 -6
  92. package/lib/ReactTransitionEvents.js +1 -1
  93. package/lib/ReactTransitionGroup.js +5 -6
  94. package/lib/ReactUpdateQueue.js +19 -19
  95. package/lib/ReactUpdates.js +15 -15
  96. package/lib/{performance.js → ReactVersion.js} +3 -12
  97. package/lib/ReactWithAddons.js +24 -15
  98. package/lib/ResponderEventPlugin.js +514 -0
  99. package/lib/ResponderSyntheticEvent.js +40 -0
  100. package/lib/ResponderTouchHistoryStore.js +180 -0
  101. package/lib/SVGDOMPropertyConfig.js +1 -1
  102. package/lib/SelectEventPlugin.js +19 -9
  103. package/lib/SimpleEventPlugin.js +198 -43
  104. package/lib/SyntheticClipboardEvent.js +1 -1
  105. package/lib/SyntheticCompositionEvent.js +1 -1
  106. package/lib/SyntheticDragEvent.js +1 -1
  107. package/lib/SyntheticEvent.js +18 -4
  108. package/lib/SyntheticFocusEvent.js +1 -1
  109. package/lib/SyntheticInputEvent.js +1 -1
  110. package/lib/SyntheticKeyboardEvent.js +4 -4
  111. package/lib/SyntheticMouseEvent.js +3 -3
  112. package/lib/SyntheticTouchEvent.js +2 -2
  113. package/lib/SyntheticUIEvent.js +2 -2
  114. package/lib/SyntheticWheelEvent.js +1 -1
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +7 -7
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -7
  120. package/lib/cloneWithProps.js +11 -6
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +7 -6
  124. package/lib/findDOMNode.js +9 -9
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/getEventKey.js +1 -1
  127. package/lib/{isTextNode.js → getTestDocument.js} +7 -11
  128. package/lib/getTextContentAccessor.js +1 -1
  129. package/lib/instantiateReactComponent.js +15 -17
  130. package/lib/isEventSupported.js +1 -1
  131. package/lib/onlyChild.js +3 -3
  132. package/lib/quoteAttributeValueForBrowser.js +1 -1
  133. package/lib/reactComponentExpect.js +216 -0
  134. package/lib/renderSubtreeIntoContainer.js +1 -1
  135. package/lib/setInnerHTML.js +1 -1
  136. package/lib/setTextContent.js +3 -3
  137. package/lib/shallowCompare.js +1 -1
  138. package/lib/shouldUpdateReactComponent.js +12 -8
  139. package/lib/sliceChildren.js +34 -0
  140. package/lib/traverseAllChildren.js +25 -18
  141. package/lib/update.js +13 -13
  142. package/lib/validateDOMNesting.js +6 -6
  143. package/lib/webcomponents.js +6379 -0
  144. package/package.json +4 -6
  145. package/react.js +1 -51
  146. package/dist/JSXTransformer.js +0 -17588
  147. package/lib/CSSCore.js +0 -97
  148. package/lib/EventListener.js +0 -84
  149. package/lib/ExecutionEnvironment.js +0 -38
  150. package/lib/ReactDOMClient.js +0 -90
  151. package/lib/camelize.js +0 -32
  152. package/lib/camelizeStyleName.js +0 -40
  153. package/lib/containsNode.js +0 -55
  154. package/lib/createArrayFromMixed.js +0 -85
  155. package/lib/createNodesFromMarkup.js +0 -84
  156. package/lib/emptyFunction.js +0 -38
  157. package/lib/focusNode.js +0 -26
  158. package/lib/getActiveElement.js +0 -29
  159. package/lib/getMarkupWrap.js +0 -93
  160. package/lib/getUnboundedScrollPosition.js +0 -38
  161. package/lib/hyphenate.js +0 -33
  162. package/lib/hyphenateStyleName.js +0 -39
  163. package/lib/invariant.js +0 -49
  164. package/lib/isNode.js +0 -23
  165. package/lib/joinClasses.js +0 -39
  166. package/lib/keyMirror.js +0 -48
  167. package/lib/keyOf.js +0 -35
  168. package/lib/mapObject.js +0 -51
  169. package/lib/memoizeStringOnly.js +0 -31
  170. package/lib/performanceNow.js +0 -28
  171. package/lib/shallowEqual.js +0 -48
  172. package/lib/toArray.js +0 -57
  173. package/lib/warning.js +0 -57
@@ -11,8 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactDOMIDOperations = require("./ReactDOMIDOperations");
15
- var ReactMount = require("./ReactMount");
14
+ var ReactDOMIDOperations = require('./ReactDOMIDOperations');
15
+ var ReactMount = require('./ReactMount');
16
16
 
17
17
  /**
18
18
  * Abstracts away all functionality of the reconciler that requires knowledge of
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var invariant = require("./invariant");
14
+ var invariant = require('fbjs/lib/invariant');
15
15
 
16
16
  var injected = false;
17
17
 
@@ -38,7 +38,7 @@ var ReactComponentEnvironment = {
38
38
 
39
39
  injection: {
40
40
  injectEnvironment: function (environment) {
41
- !!injected ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined;
41
+ !!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined;
42
42
  ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
43
43
  ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID;
44
44
  ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var shallowCompare = require("./shallowCompare");
14
+ var shallowCompare = require('./shallowCompare');
15
15
 
16
16
  /**
17
17
  * If your React component's render function is "pure", e.g. it will render the
@@ -11,21 +11,21 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactComponentEnvironment = require("./ReactComponentEnvironment");
15
- var ReactCurrentOwner = require("./ReactCurrentOwner");
16
- var ReactElement = require("./ReactElement");
17
- var ReactInstanceMap = require("./ReactInstanceMap");
18
- var ReactPerf = require("./ReactPerf");
19
- var ReactPropTypeLocations = require("./ReactPropTypeLocations");
20
- var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
21
- var ReactReconciler = require("./ReactReconciler");
22
- var ReactUpdateQueue = require("./ReactUpdateQueue");
23
-
24
- var assign = require("./Object.assign");
25
- var emptyObject = require("./emptyObject");
26
- var invariant = require("./invariant");
27
- var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
28
- var warning = require("./warning");
14
+ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
15
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
16
+ var ReactElement = require('./ReactElement');
17
+ var ReactInstanceMap = require('./ReactInstanceMap');
18
+ var ReactPerf = require('./ReactPerf');
19
+ var ReactPropTypeLocations = require('./ReactPropTypeLocations');
20
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
21
+ var ReactReconciler = require('./ReactReconciler');
22
+ var ReactUpdateQueue = require('./ReactUpdateQueue');
23
+
24
+ var assign = require('./Object.assign');
25
+ var emptyObject = require('fbjs/lib/emptyObject');
26
+ var invariant = require('fbjs/lib/invariant');
27
+ var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
28
+ var warning = require('fbjs/lib/warning');
29
29
 
30
30
  function getDeclarationErrorAddendum(component) {
31
31
  var owner = component._currentElement._owner || null;
@@ -38,6 +38,12 @@ function getDeclarationErrorAddendum(component) {
38
38
  return '';
39
39
  }
40
40
 
41
+ function StatelessComponent(Component) {}
42
+ StatelessComponent.prototype.render = function () {
43
+ var Component = ReactInstanceMap.get(this)._currentElement.type;
44
+ return Component(this.props, this.context, this.updater);
45
+ };
46
+
41
47
  /**
42
48
  * ------------------ The Life-Cycle of a Composite Component ------------------
43
49
  *
@@ -126,12 +132,43 @@ var ReactCompositeComponentMixin = {
126
132
  var Component = this._currentElement.type;
127
133
 
128
134
  // Initialize the public class
129
- var inst = new Component(publicProps, publicContext, ReactUpdateQueue);
135
+ var inst;
136
+ var renderedElement;
137
+
138
+ // This is a way to detect if Component is a stateless arrow function
139
+ // component, which is not newable. It might not be 100% reliable but is
140
+ // something we can do until we start detecting that Component extends
141
+ // React.Component. We already assume that typeof Component === 'function'.
142
+ var canInstantiate = ('prototype' in Component);
143
+
144
+ if (canInstantiate) {
145
+ if (process.env.NODE_ENV !== 'production') {
146
+ ReactCurrentOwner.current = this;
147
+ try {
148
+ inst = new Component(publicProps, publicContext, ReactUpdateQueue);
149
+ } finally {
150
+ ReactCurrentOwner.current = null;
151
+ }
152
+ } else {
153
+ inst = new Component(publicProps, publicContext, ReactUpdateQueue);
154
+ }
155
+ }
156
+
157
+ if (!canInstantiate || inst === null || inst === false || ReactElement.isValidElement(inst)) {
158
+ renderedElement = inst;
159
+ inst = new StatelessComponent(Component);
160
+ }
130
161
 
131
- if ('production' !== process.env.NODE_ENV) {
162
+ if (process.env.NODE_ENV !== 'production') {
132
163
  // This will throw later in _renderValidatedComponent, but add an early
133
164
  // warning now to help debugging
134
- 'production' !== process.env.NODE_ENV ? warning(inst.render != null, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render` in your ' + 'component or you may have accidentally tried to render an element ' + 'whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : undefined;
165
+ if (inst.render == null) {
166
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`, returned ' + 'null/false from a stateless component, or tried to render an ' + 'element whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : undefined;
167
+ } else {
168
+ // We support ES6 inheriting from React.Component, the module pattern,
169
+ // and stateless components, but not ES6 classes that don't extend
170
+ process.env.NODE_ENV !== 'production' ? warning(Component.prototype && Component.prototype.isReactComponent || !canInstantiate || !(inst instanceof Component), '%s(...): React component classes must extend React.Component.', Component.displayName || Component.name || 'Component') : undefined;
171
+ }
135
172
  }
136
173
 
137
174
  // These should be set up in the constructor, but as a convenience for
@@ -146,24 +183,24 @@ var ReactCompositeComponentMixin = {
146
183
  // Store a reference from the instance back to the internal representation
147
184
  ReactInstanceMap.set(inst, this);
148
185
 
149
- if ('production' !== process.env.NODE_ENV) {
186
+ if (process.env.NODE_ENV !== 'production') {
150
187
  // Since plain JS classes are defined without any special initialization
151
188
  // logic, we can not catch common errors early. Therefore, we have to
152
189
  // catch them here, at initialization time, instead.
153
- 'production' !== process.env.NODE_ENV ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, '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') : undefined;
154
- 'production' !== process.env.NODE_ENV ? 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') : undefined;
155
- 'production' !== process.env.NODE_ENV ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : undefined;
156
- 'production' !== process.env.NODE_ENV ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : undefined;
157
- 'production' !== process.env.NODE_ENV ? 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') : undefined;
158
- 'production' !== process.env.NODE_ENV ? 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') : undefined;
159
- 'production' !== process.env.NODE_ENV ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : undefined;
190
+ process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, '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') : undefined;
191
+ 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') : undefined;
192
+ 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') : undefined;
193
+ 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') : undefined;
194
+ 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') : undefined;
195
+ 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') : undefined;
196
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : undefined;
160
197
  }
161
198
 
162
199
  var initialState = inst.state;
163
200
  if (initialState === undefined) {
164
201
  inst.state = initialState = null;
165
202
  }
166
- !(typeof initialState === 'object' && !Array.isArray(initialState)) ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
203
+ !(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') : invariant(false) : undefined;
167
204
 
168
205
  this._pendingStateQueue = null;
169
206
  this._pendingReplaceState = false;
@@ -178,7 +215,10 @@ var ReactCompositeComponentMixin = {
178
215
  }
179
216
  }
180
217
 
181
- var renderedElement = this._renderValidatedComponent();
218
+ // If not a stateless component, we now render
219
+ if (renderedElement === undefined) {
220
+ renderedElement = this._renderValidatedComponent();
221
+ }
182
222
 
183
223
  this._renderedComponent = this._instantiateReactComponent(renderedElement);
184
224
 
@@ -205,6 +245,7 @@ var ReactCompositeComponentMixin = {
205
245
 
206
246
  ReactReconciler.unmountComponent(this._renderedComponent);
207
247
  this._renderedComponent = null;
248
+ this._instance = null;
208
249
 
209
250
  // Reset pending fields
210
251
  // Even if this component is scheduled for another update in ReactUpdates,
@@ -265,7 +306,7 @@ var ReactCompositeComponentMixin = {
265
306
  */
266
307
  _processContext: function (context) {
267
308
  var maskedContext = this._maskContext(context);
268
- if ('production' !== process.env.NODE_ENV) {
309
+ if (process.env.NODE_ENV !== 'production') {
269
310
  var Component = this._currentElement.type;
270
311
  if (Component.contextTypes) {
271
312
  this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
@@ -284,12 +325,12 @@ var ReactCompositeComponentMixin = {
284
325
  var inst = this._instance;
285
326
  var childContext = inst.getChildContext && inst.getChildContext();
286
327
  if (childContext) {
287
- !(typeof Component.childContextTypes === 'object') ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
288
- if ('production' !== process.env.NODE_ENV) {
328
+ !(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') : invariant(false) : undefined;
329
+ if (process.env.NODE_ENV !== 'production') {
289
330
  this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
290
331
  }
291
332
  for (var name in childContext) {
292
- !(name in Component.childContextTypes) ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : undefined;
333
+ !(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : undefined;
293
334
  }
294
335
  return assign({}, currentContext, childContext);
295
336
  }
@@ -306,7 +347,7 @@ var ReactCompositeComponentMixin = {
306
347
  * @private
307
348
  */
308
349
  _processProps: function (newProps) {
309
- if ('production' !== process.env.NODE_ENV) {
350
+ if (process.env.NODE_ENV !== 'production') {
310
351
  var Component = this._currentElement.type;
311
352
  if (Component.propTypes) {
312
353
  this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop);
@@ -333,22 +374,22 @@ var ReactCompositeComponentMixin = {
333
374
  try {
334
375
  // This is intentionally an invariant that gets caught. It's the same
335
376
  // behavior as without this statement except with a better message.
336
- !(typeof propTypes[propName] === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
377
+ !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
337
378
  error = propTypes[propName](props, propName, componentName, location);
338
379
  } catch (ex) {
339
380
  error = ex;
340
381
  }
341
382
  if (error instanceof Error) {
342
383
  // We may want to extend this logic for similar errors in
343
- // React.render calls, so I'm abstracting it away into
384
+ // top-level render calls, so I'm abstracting it away into
344
385
  // a function to minimize refactoring in the future
345
386
  var addendum = getDeclarationErrorAddendum(this);
346
387
 
347
388
  if (location === ReactPropTypeLocations.prop) {
348
389
  // Preface gives us something to blacklist in warning module
349
- 'production' !== process.env.NODE_ENV ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : undefined;
390
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : undefined;
350
391
  } else {
351
- 'production' !== process.env.NODE_ENV ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : undefined;
392
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : undefined;
352
393
  }
353
394
  }
354
395
  }
@@ -422,8 +463,8 @@ var ReactCompositeComponentMixin = {
422
463
 
423
464
  var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
424
465
 
425
- if ('production' !== process.env.NODE_ENV) {
426
- 'production' !== process.env.NODE_ENV ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined;
466
+ if (process.env.NODE_ENV !== 'production') {
467
+ process.env.NODE_ENV !== 'production' ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined;
427
468
  }
428
469
 
429
470
  if (shouldUpdate) {
@@ -544,7 +585,7 @@ var ReactCompositeComponentMixin = {
544
585
  _renderValidatedComponentWithoutOwnerOrContext: function () {
545
586
  var inst = this._instance;
546
587
  var renderedComponent = inst.render();
547
- if ('production' !== process.env.NODE_ENV) {
588
+ if (process.env.NODE_ENV !== 'production') {
548
589
  // We allow auto-mocks to proceed as if they're returning null.
549
590
  if (typeof renderedComponent === 'undefined' && inst.render._isMockFunction) {
550
591
  // This is probably bad practice. Consider warning here and
@@ -569,7 +610,7 @@ var ReactCompositeComponentMixin = {
569
610
  }
570
611
  !(
571
612
  // TODO: An `isValidNode` function would probably be more appropriate
572
- (renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent))) ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
613
+ renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
573
614
  return renderedComponent;
574
615
  },
575
616
 
@@ -583,8 +624,14 @@ var ReactCompositeComponentMixin = {
583
624
  */
584
625
  attachRef: function (ref, component) {
585
626
  var inst = this.getPublicInstance();
627
+ !(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : invariant(false) : undefined;
628
+ var publicComponentInstance = component.getPublicInstance();
629
+ if (process.env.NODE_ENV !== 'production') {
630
+ var componentName = component && component.getName ? component.getName() : 'a component';
631
+ process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null, '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()) : undefined;
632
+ }
586
633
  var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
587
- refs[ref] = component.getPublicInstance();
634
+ refs[ref] = publicComponentInstance;
588
635
  },
589
636
 
590
637
  /**
@@ -613,14 +660,18 @@ var ReactCompositeComponentMixin = {
613
660
 
614
661
  /**
615
662
  * Get the publicly accessible representation of this component - i.e. what
616
- * is exposed by refs and returned by React.render. Can be null for stateless
663
+ * is exposed by refs and returned by render. Can be null for stateless
617
664
  * components.
618
665
  *
619
666
  * @return {ReactComponent} the public component instance.
620
667
  * @internal
621
668
  */
622
669
  getPublicInstance: function () {
623
- return this._instance;
670
+ var inst = this._instance;
671
+ if (inst instanceof StatelessComponent) {
672
+ return null;
673
+ }
674
+ return inst;
624
675
  },
625
676
 
626
677
  // Stub
package/lib/ReactDOM.js CHANGED
@@ -7,171 +7,86 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactDOM
10
- * @typechecks static-only
11
10
  */
12
11
 
12
+ /* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
13
+
13
14
  'use strict';
14
15
 
15
- var ReactElement = require("./ReactElement");
16
- var ReactElementValidator = require("./ReactElementValidator");
16
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
17
+ var ReactDOMTextComponent = require('./ReactDOMTextComponent');
18
+ var ReactDefaultInjection = require('./ReactDefaultInjection');
19
+ var ReactInstanceHandles = require('./ReactInstanceHandles');
20
+ var ReactMount = require('./ReactMount');
21
+ var ReactPerf = require('./ReactPerf');
22
+ var ReactReconciler = require('./ReactReconciler');
23
+ var ReactUpdates = require('./ReactUpdates');
24
+ var ReactVersion = require('./ReactVersion');
17
25
 
18
- var mapObject = require("./mapObject");
26
+ var findDOMNode = require('./findDOMNode');
27
+ var renderSubtreeIntoContainer = require('./renderSubtreeIntoContainer');
28
+ var warning = require('fbjs/lib/warning');
19
29
 
20
- /**
21
- * Create a factory that creates HTML tag elements.
22
- *
23
- * @param {string} tag Tag name (e.g. `div`).
24
- * @private
25
- */
26
- function createDOMFactory(tag) {
27
- if ('production' !== process.env.NODE_ENV) {
28
- return ReactElementValidator.createFactory(tag);
30
+ ReactDefaultInjection.inject();
31
+
32
+ var render = ReactPerf.measure('React', 'render', ReactMount.render);
33
+
34
+ var React = {
35
+ findDOMNode: findDOMNode,
36
+ render: render,
37
+ unmountComponentAtNode: ReactMount.unmountComponentAtNode,
38
+ version: ReactVersion,
39
+
40
+ /* eslint-disable camelcase */
41
+ unstable_batchedUpdates: ReactUpdates.batchedUpdates,
42
+ unstable_renderSubtreeIntoContainer: renderSubtreeIntoContainer
43
+ };
44
+
45
+ // Inject the runtime into a devtools global hook regardless of browser.
46
+ // Allows for debugging when the hook is injected on the page.
47
+ /* eslint-enable camelcase */
48
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
49
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
50
+ CurrentOwner: ReactCurrentOwner,
51
+ InstanceHandles: ReactInstanceHandles,
52
+ Mount: ReactMount,
53
+ Reconciler: ReactReconciler,
54
+ TextComponent: ReactDOMTextComponent
55
+ });
56
+ }
57
+
58
+ if (process.env.NODE_ENV !== 'production') {
59
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
60
+ if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
61
+
62
+ // First check if devtools is not installed
63
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
64
+ // If we're in Chrome or Firefox, provide a download link if not installed.
65
+ if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
66
+ console.debug('Download the React DevTools for a better development experience: ' + 'https://fb.me/react-devtools');
67
+ }
68
+ }
69
+
70
+ // If we're in IE8, check to see if we are in compatibility mode and provide
71
+ // information on preventing compatibility mode
72
+ var ieCompatibilityMode = document.documentMode && document.documentMode < 8;
73
+
74
+ process.env.NODE_ENV !== 'production' ? warning(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '<meta http-equiv="X-UA-Compatible" content="IE=edge" />') : undefined;
75
+
76
+ var expectedFeatures = [
77
+ // shims
78
+ Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim,
79
+
80
+ // shams
81
+ Object.create, Object.freeze];
82
+
83
+ for (var i = 0; i < expectedFeatures.length; i++) {
84
+ if (!expectedFeatures[i]) {
85
+ console.error('One or more ES5 shim/shams expected by React are not available: ' + 'https://fb.me/react-warning-polyfills');
86
+ break;
87
+ }
88
+ }
29
89
  }
30
- return ReactElement.createFactory(tag);
31
90
  }
32
91
 
33
- /**
34
- * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
35
- * This is also accessible via `React.DOM`.
36
- *
37
- * @public
38
- */
39
- var ReactDOM = mapObject({
40
- a: 'a',
41
- abbr: 'abbr',
42
- address: 'address',
43
- area: 'area',
44
- article: 'article',
45
- aside: 'aside',
46
- audio: 'audio',
47
- b: 'b',
48
- base: 'base',
49
- bdi: 'bdi',
50
- bdo: 'bdo',
51
- big: 'big',
52
- blockquote: 'blockquote',
53
- body: 'body',
54
- br: 'br',
55
- button: 'button',
56
- canvas: 'canvas',
57
- caption: 'caption',
58
- cite: 'cite',
59
- code: 'code',
60
- col: 'col',
61
- colgroup: 'colgroup',
62
- data: 'data',
63
- datalist: 'datalist',
64
- dd: 'dd',
65
- del: 'del',
66
- details: 'details',
67
- dfn: 'dfn',
68
- dialog: 'dialog',
69
- div: 'div',
70
- dl: 'dl',
71
- dt: 'dt',
72
- em: 'em',
73
- embed: 'embed',
74
- fieldset: 'fieldset',
75
- figcaption: 'figcaption',
76
- figure: 'figure',
77
- footer: 'footer',
78
- form: 'form',
79
- h1: 'h1',
80
- h2: 'h2',
81
- h3: 'h3',
82
- h4: 'h4',
83
- h5: 'h5',
84
- h6: 'h6',
85
- head: 'head',
86
- header: 'header',
87
- hgroup: 'hgroup',
88
- hr: 'hr',
89
- html: 'html',
90
- i: 'i',
91
- iframe: 'iframe',
92
- img: 'img',
93
- input: 'input',
94
- ins: 'ins',
95
- kbd: 'kbd',
96
- keygen: 'keygen',
97
- label: 'label',
98
- legend: 'legend',
99
- li: 'li',
100
- link: 'link',
101
- main: 'main',
102
- map: 'map',
103
- mark: 'mark',
104
- menu: 'menu',
105
- menuitem: 'menuitem',
106
- meta: 'meta',
107
- meter: 'meter',
108
- nav: 'nav',
109
- noscript: 'noscript',
110
- object: 'object',
111
- ol: 'ol',
112
- optgroup: 'optgroup',
113
- option: 'option',
114
- output: 'output',
115
- p: 'p',
116
- param: 'param',
117
- picture: 'picture',
118
- pre: 'pre',
119
- progress: 'progress',
120
- q: 'q',
121
- rp: 'rp',
122
- rt: 'rt',
123
- ruby: 'ruby',
124
- s: 's',
125
- samp: 'samp',
126
- script: 'script',
127
- section: 'section',
128
- select: 'select',
129
- small: 'small',
130
- source: 'source',
131
- span: 'span',
132
- strong: 'strong',
133
- style: 'style',
134
- sub: 'sub',
135
- summary: 'summary',
136
- sup: 'sup',
137
- table: 'table',
138
- tbody: 'tbody',
139
- td: 'td',
140
- textarea: 'textarea',
141
- tfoot: 'tfoot',
142
- th: 'th',
143
- thead: 'thead',
144
- time: 'time',
145
- title: 'title',
146
- tr: 'tr',
147
- track: 'track',
148
- u: 'u',
149
- ul: 'ul',
150
- 'var': 'var',
151
- video: 'video',
152
- wbr: 'wbr',
153
-
154
- // SVG
155
- circle: 'circle',
156
- clipPath: 'clipPath',
157
- defs: 'defs',
158
- ellipse: 'ellipse',
159
- g: 'g',
160
- image: 'image',
161
- line: 'line',
162
- linearGradient: 'linearGradient',
163
- mask: 'mask',
164
- path: 'path',
165
- pattern: 'pattern',
166
- polygon: 'polygon',
167
- polyline: 'polyline',
168
- radialGradient: 'radialGradient',
169
- rect: 'rect',
170
- stop: 'stop',
171
- svg: 'svg',
172
- text: 'text',
173
- tspan: 'tspan'
174
-
175
- }, createDOMFactory);
176
-
177
- module.exports = ReactDOM;
92
+ module.exports = React;