react 15.1.0 → 15.2.0-rc.1

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 (109) hide show
  1. package/dist/react-with-addons.js +2034 -1313
  2. package/dist/react-with-addons.min.js +7 -6
  3. package/dist/react.js +1832 -1244
  4. package/dist/react.min.js +6 -6
  5. package/lib/CSSPropertyOperations.js +1 -1
  6. package/lib/CallbackQueue.js +3 -2
  7. package/lib/DOMChildrenOperations.js +9 -9
  8. package/lib/DOMLazyTree.js +3 -2
  9. package/lib/DOMProperty.js +6 -4
  10. package/lib/DOMPropertyOperations.js +17 -3
  11. package/lib/Danger.js +10 -8
  12. package/lib/DisabledInputUtils.js +5 -5
  13. package/lib/EventPluginHub.js +8 -2
  14. package/lib/EventPluginRegistry.js +13 -7
  15. package/lib/EventPluginUtils.js +3 -1
  16. package/lib/HTMLDOMPropertyConfig.js +1 -2
  17. package/lib/LinkedValueUtils.js +5 -3
  18. package/lib/NativeMethodsMixin.js +6 -4
  19. package/lib/PooledClass.js +3 -1
  20. package/lib/React.js +1 -1
  21. package/lib/ReactCSSTransitionGroupChild.js +15 -8
  22. package/lib/ReactChildReconciler.js +15 -6
  23. package/lib/ReactClass.js +14 -13
  24. package/lib/ReactComponent.js +3 -6
  25. package/lib/ReactComponentEnvironment.js +3 -1
  26. package/lib/ReactComponentTreeDevtool.js +94 -16
  27. package/lib/ReactComponentTreeTestUtils.js +87 -0
  28. package/lib/ReactCompositeComponent.js +66 -106
  29. package/lib/ReactDOM.js +2 -2
  30. package/lib/ReactDOMButton.js +2 -2
  31. package/lib/ReactDOMComponent.js +130 -76
  32. package/lib/ReactDOMComponentTree.js +23 -21
  33. package/lib/ReactDOMDebugTool.js +7 -1
  34. package/lib/ReactDOMEmptyComponent.js +9 -9
  35. package/lib/ReactDOMFactories.js +1 -1
  36. package/lib/ReactDOMInput.js +52 -16
  37. package/lib/ReactDOMOption.js +40 -26
  38. package/lib/ReactDOMSelect.js +3 -3
  39. package/lib/ReactDOMTextComponent.js +21 -20
  40. package/lib/ReactDOMTextarea.js +59 -32
  41. package/lib/ReactDOMTreeTraversal.js +18 -16
  42. package/lib/ReactDOMUnknownPropertyDevtool.js +41 -15
  43. package/lib/ReactDebugTool.js +88 -27
  44. package/lib/ReactDefaultInjection.js +2 -2
  45. package/lib/ReactElement.js +64 -25
  46. package/lib/ReactElementValidator.js +26 -81
  47. package/lib/ReactEventListener.js +2 -2
  48. package/lib/ReactFragment.js +3 -1
  49. package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
  50. package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
  51. package/lib/ReactInjection.js +2 -2
  52. package/lib/ReactInstanceHandles.js +8 -6
  53. package/lib/ReactMount.js +24 -16
  54. package/lib/ReactMultiChild.js +31 -9
  55. package/lib/ReactNativeAttributePayload.js +5 -2
  56. package/lib/ReactNativeBaseComponent.js +7 -7
  57. package/lib/ReactNativeBridgeEventPlugin.js +1 -1
  58. package/lib/ReactNativeComponentTree.js +8 -6
  59. package/lib/ReactNativeDOMIDOperations.js +1 -2
  60. package/lib/ReactNativeDefaultInjection.js +9 -7
  61. package/lib/ReactNativeGlobalResponderHandler.js +1 -1
  62. package/lib/ReactNativeMount.js +1 -1
  63. package/lib/ReactNativeTagHandles.js +3 -1
  64. package/lib/ReactNativeTextComponent.js +10 -9
  65. package/lib/ReactNativeTreeTraversal.js +11 -11
  66. package/lib/ReactNodeTypes.js +5 -3
  67. package/lib/ReactNoop.js +76 -0
  68. package/lib/ReactOwner.js +4 -2
  69. package/lib/ReactPerf.js +83 -7
  70. package/lib/ReactPropTypes.js +23 -0
  71. package/lib/ReactReconcileTransaction.js +1 -1
  72. package/lib/ReactReconciler.js +12 -7
  73. package/lib/ReactServerRendering.js +4 -2
  74. package/lib/ReactSimpleEmptyComponent.js +4 -4
  75. package/lib/ReactTestMount.js +126 -0
  76. package/lib/ReactTestReconcileTransaction.js +100 -0
  77. package/lib/ReactTestRenderer.js +133 -0
  78. package/lib/ReactTestUtils.js +17 -10
  79. package/lib/ReactTransitionChildMapping.js +7 -1
  80. package/lib/ReactTransitionGroup.js +40 -6
  81. package/lib/ReactUpdateQueue.js +9 -1
  82. package/lib/ReactUpdates.js +9 -8
  83. package/lib/ReactVersion.js +1 -1
  84. package/lib/ResponderEventPlugin.js +8 -6
  85. package/lib/ResponderTouchHistoryStore.js +6 -4
  86. package/lib/SimpleEventPlugin.js +3 -1
  87. package/lib/SyntheticEvent.js +2 -3
  88. package/lib/SyntheticUIEvent.js +1 -1
  89. package/lib/Transaction.js +4 -2
  90. package/lib/accumulate.js +3 -1
  91. package/lib/accumulateInto.js +3 -1
  92. package/lib/checkReactTypeSpec.js +71 -0
  93. package/lib/createReactNativeComponentClass.js +2 -2
  94. package/lib/dangerousStyleValue.js +3 -1
  95. package/lib/escapeTextContentForBrowser.js +96 -12
  96. package/lib/findDOMNode.js +6 -4
  97. package/lib/findNodeHandle.js +5 -3
  98. package/lib/flattenChildren.js +13 -4
  99. package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
  100. package/lib/instantiateReactComponent.js +13 -12
  101. package/lib/onlyChild.js +3 -1
  102. package/lib/reactComponentExpect.js +3 -3
  103. package/lib/reactProdInvariant.js +38 -0
  104. package/lib/setInnerHTML.js +17 -1
  105. package/lib/setTextContent.js +8 -0
  106. package/lib/traverseAllChildren.js +3 -1
  107. package/lib/update.js +12 -11
  108. package/package.json +2 -2
  109. package/lib/MetaMatchers.js +0 -118
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Copyright 2016-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule ReactComponentTreeTestUtils
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _assign = require('object-assign');
15
+
16
+ var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
17
+
18
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+
20
+ var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
21
+
22
+ function getRootDisplayNames() {
23
+ return ReactComponentTreeDevtool.getRootIDs().map(ReactComponentTreeDevtool.getDisplayName);
24
+ }
25
+
26
+ function getRegisteredDisplayNames() {
27
+ return ReactComponentTreeDevtool.getRegisteredIDs().map(ReactComponentTreeDevtool.getDisplayName);
28
+ }
29
+
30
+ function expectTree(rootID, expectedTree, parentPath) {
31
+ var displayName = ReactComponentTreeDevtool.getDisplayName(rootID);
32
+ var ownerID = ReactComponentTreeDevtool.getOwnerID(rootID);
33
+ var parentID = ReactComponentTreeDevtool.getParentID(rootID);
34
+ var childIDs = ReactComponentTreeDevtool.getChildIDs(rootID);
35
+ var text = ReactComponentTreeDevtool.getText(rootID);
36
+ var element = ReactComponentTreeDevtool.getElement(rootID);
37
+ var path = parentPath ? parentPath + ' > ' + displayName : displayName;
38
+
39
+ function expectEqual(actual, expected, name) {
40
+ // Get Jasmine to print descriptive error messages.
41
+ // We pass path so that we know where the mismatch occurred.
42
+ expect(_defineProperty({
43
+ path: path
44
+ }, name, actual)).toEqual(_defineProperty({
45
+ path: path
46
+ }, name, expected));
47
+ }
48
+
49
+ if (expectedTree.parentDisplayName !== undefined) {
50
+ expectEqual(ReactComponentTreeDevtool.getDisplayName(parentID), expectedTree.parentDisplayName, 'parentDisplayName');
51
+ }
52
+ if (expectedTree.ownerDisplayName !== undefined) {
53
+ expectEqual(ReactComponentTreeDevtool.getDisplayName(ownerID), expectedTree.ownerDisplayName, 'ownerDisplayName');
54
+ }
55
+ if (expectedTree.parentID !== undefined) {
56
+ expectEqual(parentID, expectedTree.parentID, 'parentID');
57
+ }
58
+ if (expectedTree.text !== undefined) {
59
+ expectEqual(text, expectedTree.text, 'text');
60
+ expectEqual('' + element, expectedTree.text, 'element.toString()');
61
+ } else {
62
+ expectEqual(text, null, 'text');
63
+ }
64
+ if (expectedTree.element !== undefined) {
65
+ // TODO: Comparing elements makes tests run out of memory on errors.
66
+ // For now, compare just types.
67
+ expectEqual(element && element.type, expectedTree.element && expectedTree.element.type, 'element.type');
68
+ } else if (text == null) {
69
+ expectEqual(typeof element, 'object', 'typeof element');
70
+ }
71
+ if (expectedTree.children !== undefined) {
72
+ expectEqual(childIDs.length, expectedTree.children.length, 'children.length');
73
+ for (var i = 0; i < childIDs.length; i++) {
74
+ expectTree(childIDs[i], _extends({ parentID: rootID }, expectedTree.children[i]), path);
75
+ }
76
+ } else {
77
+ expectEqual(childIDs, [], 'childIDs');
78
+ }
79
+ }
80
+
81
+ var ReactComponentTreeTestUtils = {
82
+ expectTree: expectTree,
83
+ getRootDisplayNames: getRootDisplayNames,
84
+ getRegisteredDisplayNames: getRegisteredDisplayNames
85
+ };
86
+
87
+ module.exports = ReactComponentTreeTestUtils;
@@ -11,7 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var _assign = require('object-assign');
14
+ var _prodInvariant = require('./reactProdInvariant'),
15
+ _assign = require('object-assign');
15
16
 
16
17
  var ReactComponentEnvironment = require('./ReactComponentEnvironment');
17
18
  var ReactCurrentOwner = require('./ReactCurrentOwner');
@@ -21,26 +22,16 @@ var ReactInstanceMap = require('./ReactInstanceMap');
21
22
  var ReactInstrumentation = require('./ReactInstrumentation');
22
23
  var ReactNodeTypes = require('./ReactNodeTypes');
23
24
  var ReactPropTypeLocations = require('./ReactPropTypeLocations');
24
- var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
25
25
  var ReactReconciler = require('./ReactReconciler');
26
26
  var ReactUpdateQueue = require('./ReactUpdateQueue');
27
27
 
28
+ var checkReactTypeSpec = require('./checkReactTypeSpec');
29
+
28
30
  var emptyObject = require('fbjs/lib/emptyObject');
29
31
  var invariant = require('fbjs/lib/invariant');
30
32
  var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
31
33
  var warning = require('fbjs/lib/warning');
32
34
 
33
- function getDeclarationErrorAddendum(component) {
34
- var owner = component._currentElement._owner || null;
35
- if (owner) {
36
- var name = owner.getName();
37
- if (name) {
38
- return ' Check the render method of `' + name + '`.';
39
- }
40
- }
41
- return '';
42
- }
43
-
44
35
  function StatelessComponent(Component) {}
45
36
  StatelessComponent.prototype.render = function () {
46
37
  var Component = ReactInstanceMap.get(this)._currentElement.type;
@@ -52,6 +43,7 @@ StatelessComponent.prototype.render = function () {
52
43
  function warnIfInvalidElement(Component, element) {
53
44
  if (process.env.NODE_ENV !== 'production') {
54
45
  process.env.NODE_ENV !== 'production' ? warning(element === null || element === false || ReactElement.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;
46
+ process.env.NODE_ENV !== 'production' ? warning(!Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component') : void 0;
55
47
  }
56
48
  }
57
49
 
@@ -132,8 +124,8 @@ var ReactCompositeComponentMixin = {
132
124
  this._currentElement = element;
133
125
  this._rootNodeID = null;
134
126
  this._instance = null;
135
- this._nativeParent = null;
136
- this._nativeContainerInfo = null;
127
+ this._hostParent = null;
128
+ this._hostContainerInfo = null;
137
129
 
138
130
  // See ReactUpdateQueue
139
131
  this._updateBatchNumber = null;
@@ -153,26 +145,30 @@ var ReactCompositeComponentMixin = {
153
145
 
154
146
  // ComponentWillUnmount shall only be called once
155
147
  this._calledComponentWillUnmount = false;
148
+
149
+ if (process.env.NODE_ENV !== 'production') {
150
+ this._warnedAboutRefsInRender = false;
151
+ }
156
152
  },
157
153
 
158
154
  /**
159
155
  * Initializes the component, renders markup, and registers event listeners.
160
156
  *
161
157
  * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
162
- * @param {?object} nativeParent
163
- * @param {?object} nativeContainerInfo
158
+ * @param {?object} hostParent
159
+ * @param {?object} hostContainerInfo
164
160
  * @param {?object} context
165
161
  * @return {?string} Rendered markup to be inserted into the DOM.
166
162
  * @final
167
163
  * @internal
168
164
  */
169
- mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
165
+ mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
170
166
  this._context = context;
171
167
  this._mountOrder = nextMountID++;
172
- this._nativeParent = nativeParent;
173
- this._nativeContainerInfo = nativeContainerInfo;
168
+ this._hostParent = hostParent;
169
+ this._hostContainerInfo = hostContainerInfo;
174
170
 
175
- var publicProps = this._processProps(this._currentElement.props);
171
+ var publicProps = this._currentElement.props;
176
172
  var publicContext = this._processContext(context);
177
173
 
178
174
  var Component = this._currentElement.type;
@@ -185,7 +181,7 @@ var ReactCompositeComponentMixin = {
185
181
  if (!shouldConstruct(Component) && (inst == null || inst.render == null)) {
186
182
  renderedElement = inst;
187
183
  warnIfInvalidElement(Component, renderedElement);
188
- !(inst === null || inst === false || ReactElement.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') : invariant(false) : void 0;
184
+ !(inst === null || inst === false || ReactElement.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;
189
185
  inst = new StatelessComponent(Component);
190
186
  }
191
187
 
@@ -231,7 +227,7 @@ var ReactCompositeComponentMixin = {
231
227
  if (initialState === undefined) {
232
228
  inst.state = initialState = null;
233
229
  }
234
- !(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) : void 0;
230
+ !(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;
235
231
 
236
232
  this._pendingStateQueue = null;
237
233
  this._pendingReplaceState = false;
@@ -239,9 +235,9 @@ var ReactCompositeComponentMixin = {
239
235
 
240
236
  var markup;
241
237
  if (inst.unstable_handleError) {
242
- markup = this.performInitialMountWithErrorHandling(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
238
+ markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context);
243
239
  } else {
244
- markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
240
+ markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
245
241
  }
246
242
 
247
243
  if (inst.componentDidMount) {
@@ -301,11 +297,11 @@ var ReactCompositeComponentMixin = {
301
297
  return instanceOrElement;
302
298
  },
303
299
 
304
- performInitialMountWithErrorHandling: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
300
+ performInitialMountWithErrorHandling: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
305
301
  var markup;
306
302
  var checkpoint = transaction.checkpoint();
307
303
  try {
308
- markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
304
+ markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
309
305
  } catch (e) {
310
306
  // Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
311
307
  transaction.rollback(checkpoint);
@@ -320,12 +316,12 @@ var ReactCompositeComponentMixin = {
320
316
 
321
317
  // Try again - we've informed the component about the error, so they can render an error message this time.
322
318
  // If this throws again, the error will bubble up (and can be caught by a higher error boundary).
323
- markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
319
+ markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
324
320
  }
325
321
  return markup;
326
322
  },
327
323
 
328
- performInitialMount: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
324
+ performInitialMount: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
329
325
  var inst = this._instance;
330
326
  if (inst.componentWillMount) {
331
327
  if (process.env.NODE_ENV !== 'production') {
@@ -352,21 +348,27 @@ var ReactCompositeComponentMixin = {
352
348
  }
353
349
 
354
350
  this._renderedNodeType = ReactNodeTypes.getType(renderedElement);
355
- this._renderedComponent = this._instantiateReactComponent(renderedElement);
351
+ var child = this._instantiateReactComponent(renderedElement);
352
+ this._renderedComponent = child;
353
+ if (process.env.NODE_ENV !== 'production') {
354
+ if (child._debugID !== 0 && this._debugID !== 0) {
355
+ ReactInstrumentation.debugTool.onSetParent(child._debugID, this._debugID);
356
+ }
357
+ }
356
358
 
357
- var markup = ReactReconciler.mountComponent(this._renderedComponent, transaction, nativeParent, nativeContainerInfo, this._processChildContext(context));
359
+ var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context));
358
360
 
359
361
  if (process.env.NODE_ENV !== 'production') {
360
362
  if (this._debugID !== 0) {
361
- ReactInstrumentation.debugTool.onSetChildren(this._debugID, this._renderedComponent._debugID !== 0 ? [this._renderedComponent._debugID] : []);
363
+ ReactInstrumentation.debugTool.onSetChildren(this._debugID, child._debugID !== 0 ? [child._debugID] : []);
362
364
  }
363
365
  }
364
366
 
365
367
  return markup;
366
368
  },
367
369
 
368
- getNativeNode: function () {
369
- return ReactReconciler.getNativeNode(this._renderedComponent);
370
+ getHostNode: function () {
371
+ return ReactReconciler.getHostNode(this._renderedComponent);
370
372
  },
371
373
 
372
374
  /**
@@ -469,7 +471,7 @@ var ReactCompositeComponentMixin = {
469
471
  if (process.env.NODE_ENV !== 'production') {
470
472
  var Component = this._currentElement.type;
471
473
  if (Component.contextTypes) {
472
- this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
474
+ this._checkContextTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
473
475
  }
474
476
  }
475
477
  return maskedContext;
@@ -491,12 +493,12 @@ var ReactCompositeComponentMixin = {
491
493
  ReactInstrumentation.debugTool.onEndProcessingChildContext();
492
494
  }
493
495
  if (childContext) {
494
- !(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) : void 0;
496
+ !(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;
495
497
  if (process.env.NODE_ENV !== 'production') {
496
- this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
498
+ this._checkContextTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
497
499
  }
498
500
  for (var name in childContext) {
499
- !(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) : void 0;
501
+ !(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;
500
502
  }
501
503
  return _assign({}, currentContext, childContext);
502
504
  }
@@ -504,62 +506,15 @@ var ReactCompositeComponentMixin = {
504
506
  },
505
507
 
506
508
  /**
507
- * Processes props by setting default values for unspecified props and
508
- * asserting that the props are valid. Does not mutate its argument; returns
509
- * a new props object with defaults merged in.
510
- *
511
- * @param {object} newProps
512
- * @return {object}
513
- * @private
514
- */
515
- _processProps: function (newProps) {
516
- if (process.env.NODE_ENV !== 'production') {
517
- var Component = this._currentElement.type;
518
- if (Component.propTypes) {
519
- this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop);
520
- }
521
- }
522
- return newProps;
523
- },
524
-
525
- /**
526
- * Assert that the props are valid
509
+ * Assert that the context types are valid
527
510
  *
528
- * @param {object} propTypes Map of prop name to a ReactPropType
529
- * @param {object} props
511
+ * @param {object} typeSpecs Map of context field to a ReactPropType
512
+ * @param {object} values Runtime values that need to be type-checked
530
513
  * @param {string} location e.g. "prop", "context", "child context"
531
514
  * @private
532
515
  */
533
- _checkPropTypes: function (propTypes, props, location) {
534
- // TODO: Stop validating prop types here and only use the element
535
- // validation.
536
- var componentName = this.getName();
537
- for (var propName in propTypes) {
538
- if (propTypes.hasOwnProperty(propName)) {
539
- var error;
540
- try {
541
- // This is intentionally an invariant that gets caught. It's the same
542
- // behavior as without this statement except with a better message.
543
- !(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) : void 0;
544
- error = propTypes[propName](props, propName, componentName, location);
545
- } catch (ex) {
546
- error = ex;
547
- }
548
- if (error instanceof Error) {
549
- // We may want to extend this logic for similar errors in
550
- // top-level render calls, so I'm abstracting it away into
551
- // a function to minimize refactoring in the future
552
- var addendum = getDeclarationErrorAddendum(this);
553
-
554
- if (location === ReactPropTypeLocations.prop) {
555
- // Preface gives us something to blacklist in warning module
556
- process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : void 0;
557
- } else {
558
- process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : void 0;
559
- }
560
- }
561
- }
562
- }
516
+ _checkContextTypes: function (typeSpecs, values, location) {
517
+ checkReactTypeSpec(typeSpecs, values, location, this.getName(), null, this._debugID);
563
518
  },
564
519
 
565
520
  receiveComponent: function (nextElement, transaction, nextContext) {
@@ -605,6 +560,8 @@ var ReactCompositeComponentMixin = {
605
560
  */
606
561
  updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
607
562
  var inst = this._instance;
563
+ !(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;
564
+
608
565
  var willReceive = false;
609
566
  var nextContext;
610
567
  var nextProps;
@@ -617,13 +574,10 @@ var ReactCompositeComponentMixin = {
617
574
  willReceive = true;
618
575
  }
619
576
 
620
- // Distinguish between a props update versus a simple state update
621
- if (prevParentElement === nextParentElement) {
622
- // Skip checking prop types again -- we don't read inst.props to avoid
623
- // warning for DOM component props in this upgrade
624
- nextProps = nextParentElement.props;
625
- } else {
626
- nextProps = this._processProps(nextParentElement.props);
577
+ nextProps = nextParentElement.props;
578
+
579
+ // Not a simple state update but a props update
580
+ if (prevParentElement !== nextParentElement) {
627
581
  willReceive = true;
628
582
  }
629
583
 
@@ -774,21 +728,27 @@ var ReactCompositeComponentMixin = {
774
728
  if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
775
729
  ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
776
730
  } else {
777
- var oldNativeNode = ReactReconciler.getNativeNode(prevComponentInstance);
731
+ var oldHostNode = ReactReconciler.getHostNode(prevComponentInstance);
778
732
  ReactReconciler.unmountComponent(prevComponentInstance, false);
779
733
 
780
734
  this._renderedNodeType = ReactNodeTypes.getType(nextRenderedElement);
781
- this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
735
+ var child = this._instantiateReactComponent(nextRenderedElement);
736
+ this._renderedComponent = child;
737
+ if (process.env.NODE_ENV !== 'production') {
738
+ if (child._debugID !== 0 && this._debugID !== 0) {
739
+ ReactInstrumentation.debugTool.onSetParent(child._debugID, this._debugID);
740
+ }
741
+ }
782
742
 
783
- var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, transaction, this._nativeParent, this._nativeContainerInfo, this._processChildContext(context));
743
+ var nextMarkup = ReactReconciler.mountComponent(child, transaction, this._hostParent, this._hostContainerInfo, this._processChildContext(context));
784
744
 
785
745
  if (process.env.NODE_ENV !== 'production') {
786
746
  if (this._debugID !== 0) {
787
- ReactInstrumentation.debugTool.onSetChildren(this._debugID, this._renderedComponent._debugID !== 0 ? [this._renderedComponent._debugID] : []);
747
+ ReactInstrumentation.debugTool.onSetChildren(this._debugID, child._debugID !== 0 ? [child._debugID] : []);
788
748
  }
789
749
  }
790
750
 
791
- this._replaceNodeWithMarkup(oldNativeNode, nextMarkup, prevComponentInstance);
751
+ this._replaceNodeWithMarkup(oldHostNode, nextMarkup, prevComponentInstance);
792
752
  }
793
753
  },
794
754
 
@@ -797,8 +757,8 @@ var ReactCompositeComponentMixin = {
797
757
  *
798
758
  * @protected
799
759
  */
800
- _replaceNodeWithMarkup: function (oldNativeNode, nextMarkup, prevInstance) {
801
- ReactComponentEnvironment.replaceNodeWithMarkup(oldNativeNode, nextMarkup, prevInstance);
760
+ _replaceNodeWithMarkup: function (oldHostNode, nextMarkup, prevInstance) {
761
+ ReactComponentEnvironment.replaceNodeWithMarkup(oldHostNode, nextMarkup, prevInstance);
802
762
  },
803
763
 
804
764
  /**
@@ -844,7 +804,7 @@ var ReactCompositeComponentMixin = {
844
804
  }
845
805
  !(
846
806
  // TODO: An `isValidNode` function would probably be more appropriate
847
- renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? 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') : invariant(false) : void 0;
807
+ renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? 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;
848
808
 
849
809
  return renderedComponent;
850
810
  },
@@ -859,7 +819,7 @@ var ReactCompositeComponentMixin = {
859
819
  */
860
820
  attachRef: function (ref, component) {
861
821
  var inst = this.getPublicInstance();
862
- !(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : invariant(false) : void 0;
822
+ !(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : _prodInvariant('110') : void 0;
863
823
  var publicComponentInstance = component.getPublicInstance();
864
824
  if (process.env.NODE_ENV !== 'production') {
865
825
  var componentName = component && component.getName ? component.getName() : 'a component';
package/lib/ReactDOM.js CHANGED
@@ -21,7 +21,7 @@ var ReactUpdates = require('./ReactUpdates');
21
21
  var ReactVersion = require('./ReactVersion');
22
22
 
23
23
  var findDOMNode = require('./findDOMNode');
24
- var getNativeComponentFromComposite = require('./getNativeComponentFromComposite');
24
+ var getHostComponentFromComposite = require('./getHostComponentFromComposite');
25
25
  var renderSubtreeIntoContainer = require('./renderSubtreeIntoContainer');
26
26
  var warning = require('fbjs/lib/warning');
27
27
 
@@ -48,7 +48,7 @@ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVT
48
48
  getNodeFromInstance: function (inst) {
49
49
  // inst is an internal instance (but could be a composite)
50
50
  if (inst._renderedComponent) {
51
- inst = getNativeComponentFromComposite(inst);
51
+ inst = getHostComponentFromComposite(inst);
52
52
  }
53
53
  if (inst) {
54
54
  return ReactDOMComponentTree.getNodeFromInstance(inst);