react 15.0.3-alpha.2 → 15.2.0-rc.2

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 (121) hide show
  1. package/dist/react-with-addons.js +3324 -2009
  2. package/dist/react-with-addons.min.js +7 -6
  3. package/dist/react.js +2736 -2005
  4. package/dist/react.min.js +6 -6
  5. package/lib/CSSPropertyOperations.js +5 -5
  6. package/lib/CallbackQueue.js +3 -2
  7. package/lib/DOMChildrenOperations.js +42 -7
  8. package/lib/DOMLazyTree.js +9 -3
  9. package/lib/DOMProperty.js +6 -4
  10. package/lib/DOMPropertyOperations.js +35 -12
  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/LinkedStateMixin.js +1 -0
  18. package/lib/LinkedValueUtils.js +5 -3
  19. package/lib/NativeMethodsMixin.js +6 -4
  20. package/lib/PooledClass.js +3 -1
  21. package/lib/React.js +1 -1
  22. package/lib/ReactCSSTransitionGroup.js +5 -0
  23. package/lib/ReactCSSTransitionGroupChild.js +15 -8
  24. package/lib/ReactChildReconciler.js +15 -6
  25. package/lib/ReactChildren.js +9 -1
  26. package/lib/ReactClass.js +15 -13
  27. package/lib/ReactComponent.js +3 -6
  28. package/lib/ReactComponentBrowserEnvironment.js +0 -5
  29. package/lib/ReactComponentEnvironment.js +3 -1
  30. package/lib/ReactComponentTreeDevtool.js +223 -0
  31. package/lib/ReactComponentTreeTestUtils.js +87 -0
  32. package/lib/ReactComponentWithPureRenderMixin.js +2 -0
  33. package/lib/ReactCompositeComponent.js +208 -119
  34. package/lib/ReactDOM.js +3 -6
  35. package/lib/ReactDOMButton.js +2 -2
  36. package/lib/ReactDOMComponent.js +162 -68
  37. package/lib/ReactDOMComponentTree.js +23 -21
  38. package/lib/ReactDOMDebugTool.js +7 -1
  39. package/lib/ReactDOMEmptyComponent.js +9 -9
  40. package/lib/ReactDOMFactories.js +1 -1
  41. package/lib/ReactDOMIDOperations.js +0 -5
  42. package/lib/ReactDOMInput.js +56 -18
  43. package/lib/ReactDOMOption.js +40 -26
  44. package/lib/ReactDOMSelect.js +3 -3
  45. package/lib/ReactDOMTextComponent.js +28 -26
  46. package/lib/ReactDOMTextarea.js +59 -32
  47. package/lib/ReactDOMTreeTraversal.js +18 -16
  48. package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
  49. package/lib/ReactDebugTool.js +250 -11
  50. package/lib/ReactDefaultInjection.js +2 -11
  51. package/lib/ReactElement.js +90 -25
  52. package/lib/ReactElementValidator.js +26 -81
  53. package/lib/ReactEventListener.js +2 -2
  54. package/lib/ReactFragment.js +8 -3
  55. package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
  56. package/lib/ReactHostOperationHistoryDevtool.js +37 -0
  57. package/lib/ReactInjection.js +2 -4
  58. package/lib/ReactInstanceHandles.js +8 -6
  59. package/lib/ReactLink.js +3 -0
  60. package/lib/ReactMount.js +43 -20
  61. package/lib/ReactMultiChild.js +51 -8
  62. package/lib/ReactNativeAttributePayload.js +5 -2
  63. package/lib/ReactNativeBaseComponent.js +7 -7
  64. package/lib/ReactNativeBridgeEventPlugin.js +1 -1
  65. package/lib/ReactNativeComponentTree.js +8 -6
  66. package/lib/ReactNativeDOMIDOperations.js +4 -8
  67. package/lib/ReactNativeDefaultInjection.js +9 -7
  68. package/lib/ReactNativeGlobalResponderHandler.js +1 -1
  69. package/lib/ReactNativeMount.js +25 -8
  70. package/lib/ReactNativeTagHandles.js +3 -1
  71. package/lib/ReactNativeTextComponent.js +18 -9
  72. package/lib/ReactNativeTreeTraversal.js +11 -11
  73. package/lib/ReactNodeTypes.js +5 -3
  74. package/lib/ReactNoop.js +76 -0
  75. package/lib/ReactOwner.js +4 -2
  76. package/lib/ReactPerf.js +473 -75
  77. package/lib/ReactPropTypes.js +23 -0
  78. package/lib/ReactReconcileTransaction.js +1 -1
  79. package/lib/ReactReconciler.js +57 -11
  80. package/lib/ReactServerRendering.js +24 -3
  81. package/lib/ReactSimpleEmptyComponent.js +4 -4
  82. package/lib/ReactTestMount.js +126 -0
  83. package/lib/ReactTestReconcileTransaction.js +100 -0
  84. package/lib/ReactTestRenderer.js +133 -0
  85. package/lib/ReactTestUtils.js +25 -10
  86. package/lib/ReactTransitionChildMapping.js +7 -1
  87. package/lib/ReactTransitionGroup.js +44 -5
  88. package/lib/ReactUpdateQueue.js +9 -1
  89. package/lib/ReactUpdates.js +30 -11
  90. package/lib/ReactVersion.js +1 -1
  91. package/lib/ReactWithAddons.js +1 -1
  92. package/lib/ResponderEventPlugin.js +8 -6
  93. package/lib/ResponderTouchHistoryStore.js +6 -4
  94. package/lib/SimpleEventPlugin.js +3 -1
  95. package/lib/SyntheticEvent.js +2 -3
  96. package/lib/SyntheticUIEvent.js +1 -1
  97. package/lib/Transaction.js +4 -2
  98. package/lib/accumulate.js +3 -1
  99. package/lib/accumulateInto.js +3 -1
  100. package/lib/checkReactTypeSpec.js +71 -0
  101. package/lib/createReactNativeComponentClass.js +2 -2
  102. package/lib/dangerousStyleValue.js +3 -1
  103. package/lib/escapeTextContentForBrowser.js +96 -12
  104. package/lib/findDOMNode.js +8 -4
  105. package/lib/findNodeHandle.js +5 -3
  106. package/lib/flattenChildren.js +13 -4
  107. package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
  108. package/lib/instantiateReactComponent.js +44 -10
  109. package/lib/onlyChild.js +10 -5
  110. package/lib/reactComponentExpect.js +3 -3
  111. package/lib/reactProdInvariant.js +38 -0
  112. package/lib/setInnerHTML.js +17 -1
  113. package/lib/setTextContent.js +8 -0
  114. package/lib/shallowCompare.js +1 -0
  115. package/lib/traverseAllChildren.js +3 -1
  116. package/lib/update.js +16 -11
  117. package/package.json +2 -2
  118. package/lib/MetaMatchers.js +0 -118
  119. package/lib/ReactDebugInstanceMap.js +0 -102
  120. package/lib/ReactDefaultPerf.js +0 -316
  121. package/lib/ReactDefaultPerfAnalysis.js +0 -210
@@ -18,14 +18,15 @@
18
18
 
19
19
  'use strict';
20
20
 
21
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
22
+ var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
21
23
  var ReactElement = require('./ReactElement');
22
24
  var ReactPropTypeLocations = require('./ReactPropTypeLocations');
23
- var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
24
- var ReactCurrentOwner = require('./ReactCurrentOwner');
25
+
26
+ var checkReactTypeSpec = require('./checkReactTypeSpec');
25
27
 
26
28
  var canDefineProperty = require('./canDefineProperty');
27
29
  var getIteratorFn = require('./getIteratorFn');
28
- var invariant = require('fbjs/lib/invariant');
29
30
  var warning = require('fbjs/lib/warning');
30
31
 
31
32
  function getDeclarationErrorAddendum() {
@@ -45,13 +46,24 @@ function getDeclarationErrorAddendum() {
45
46
  */
46
47
  var ownerHasKeyUseWarning = {};
47
48
 
48
- var loggedTypeFailures = {};
49
+ function getCurrentComponentErrorInfo(parentType) {
50
+ var info = getDeclarationErrorAddendum();
51
+
52
+ if (!info) {
53
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
54
+ if (parentName) {
55
+ info = ' Check the top-level render call using <' + parentName + '>.';
56
+ }
57
+ }
58
+ return info;
59
+ }
49
60
 
50
61
  /**
51
62
  * Warn if the element doesn't have an explicit key assigned to it.
52
63
  * This element is in an array. The array could grow and shrink or be
53
64
  * reordered. All children that haven't already been validated are required to
54
- * have a "key" property assigned to it.
65
+ * have a "key" property assigned to it. Error statuses are cached so a warning
66
+ * will only be shown once.
55
67
  *
56
68
  * @internal
57
69
  * @param {ReactElement} element Element that requires a key.
@@ -63,54 +75,24 @@ function validateExplicitKey(element, parentType) {
63
75
  }
64
76
  element._store.validated = true;
65
77
 
66
- var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
67
- if (addenda === null) {
68
- // we already showed the warning
69
- return;
70
- }
71
- process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : void 0;
72
- }
73
-
74
- /**
75
- * Shared warning and monitoring code for the key warnings.
76
- *
77
- * @internal
78
- * @param {string} messageType A key used for de-duping warnings.
79
- * @param {ReactElement} element Component that requires a key.
80
- * @param {*} parentType element's parent's type.
81
- * @returns {?object} A set of addenda to use in the warning message, or null
82
- * if the warning has already been shown before (and shouldn't be shown again).
83
- */
84
- function getAddendaForKeyUse(messageType, element, parentType) {
85
- var addendum = getDeclarationErrorAddendum();
86
- if (!addendum) {
87
- var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
88
- if (parentName) {
89
- addendum = ' Check the top-level render call using <' + parentName + '>.';
90
- }
91
- }
78
+ var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
92
79
 
93
- var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
94
- if (memoizer[addendum]) {
95
- return null;
80
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
81
+ if (memoizer[currentComponentErrorInfo]) {
82
+ return;
96
83
  }
97
- memoizer[addendum] = true;
98
-
99
- var addenda = {
100
- parentOrOwner: addendum,
101
- url: ' See https://fb.me/react-warning-keys for more information.',
102
- childOwner: null
103
- };
84
+ memoizer[currentComponentErrorInfo] = true;
104
85
 
105
86
  // Usually the current owner is the offender, but if it accepts children as a
106
87
  // property, it may be the creator of the child that's responsible for
107
88
  // assigning it a key.
89
+ var childOwner = '';
108
90
  if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
109
91
  // Give the component that originally created this child.
110
- addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
92
+ childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
111
93
  }
112
94
 
113
- return addenda;
95
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, ReactComponentTreeDevtool.getCurrentStackAddendum(element)) : void 0;
114
96
  }
115
97
 
116
98
  /**
@@ -155,43 +137,6 @@ function validateChildKeys(node, parentType) {
155
137
  }
156
138
  }
157
139
 
158
- /**
159
- * Assert that the props are valid
160
- *
161
- * @param {string} componentName Name of the component for error messages.
162
- * @param {object} propTypes Map of prop name to a ReactPropType
163
- * @param {object} props
164
- * @param {string} location e.g. "prop", "context", "child context"
165
- * @private
166
- */
167
- function checkPropTypes(componentName, propTypes, props, location) {
168
- for (var propName in propTypes) {
169
- if (propTypes.hasOwnProperty(propName)) {
170
- var error;
171
- // Prop type validation may throw. In case they do, we don't want to
172
- // fail the render phase where it didn't fail before. So we log it.
173
- // After these have been cleaned up, we'll let them throw.
174
- try {
175
- // This is intentionally an invariant that gets caught. It's the same
176
- // behavior as without this statement except with a better message.
177
- !(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;
178
- error = propTypes[propName](props, propName, componentName, location);
179
- } catch (ex) {
180
- error = ex;
181
- }
182
- process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : void 0;
183
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
184
- // Only monitor this failure once because there tends to be a lot of the
185
- // same error.
186
- loggedTypeFailures[error.message] = true;
187
-
188
- var addendum = getDeclarationErrorAddendum();
189
- process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : void 0;
190
- }
191
- }
192
- }
193
- }
194
-
195
140
  /**
196
141
  * Given an element, validate that its props follow the propTypes definition,
197
142
  * provided by the type.
@@ -205,7 +150,7 @@ function validatePropTypes(element) {
205
150
  }
206
151
  var name = componentClass.displayName || componentClass.name;
207
152
  if (componentClass.propTypes) {
208
- checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
153
+ checkReactTypeSpec(componentClass.propTypes, element.props, ReactPropTypeLocations.prop, name, element, null);
209
154
  }
210
155
  if (typeof componentClass.getDefaultProps === 'function') {
211
156
  process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
@@ -31,8 +31,8 @@ function findParent(inst) {
31
31
  // TODO: It may be a good idea to cache this to prevent unnecessary DOM
32
32
  // traversal, but caching is difficult to do correctly without using a
33
33
  // mutation observer to listen for all DOM changes.
34
- while (inst._nativeParent) {
35
- inst = inst._nativeParent;
34
+ while (inst._hostParent) {
35
+ inst = inst._hostParent;
36
36
  }
37
37
  var rootNode = ReactDOMComponentTree.getNodeFromInstance(inst);
38
38
  var container = rootNode.parentNode;
@@ -11,6 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var ReactChildren = require('./ReactChildren');
15
17
  var ReactElement = require('./ReactElement');
16
18
 
@@ -31,8 +33,11 @@ var numericPropertyRegex = /^\d+$/;
31
33
  var warnedAboutNumeric = false;
32
34
 
33
35
  var ReactFragment = {
34
- // Wrap a keyed object in an opaque proxy that warns you if you access any
35
- // of its properties.
36
+ /**
37
+ * Wrap a keyed object in an opaque proxy that warns you if you access any
38
+ * of its properties.
39
+ * See https://facebook.github.io/react/docs/create-fragment.html
40
+ */
36
41
  create: function (object) {
37
42
  if (typeof object !== 'object' || !object || Array.isArray(object)) {
38
43
  process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : void 0;
@@ -43,7 +48,7 @@ var ReactFragment = {
43
48
  return object;
44
49
  }
45
50
 
46
- !(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) : void 0;
51
+ !(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM elements are not valid children of React components.') : _prodInvariant('0') : void 0;
47
52
 
48
53
  var result = [];
49
54
 
@@ -6,22 +6,22 @@
6
6
  * LICENSE file in the root directory of this source tree. An additional grant
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
- * @providesModule ReactNativeComponent
9
+ * @providesModule ReactHostComponent
10
10
  */
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 invariant = require('fbjs/lib/invariant');
17
18
 
18
- var autoGenerateWrapperClass = null;
19
19
  var genericComponentClass = null;
20
- // This registry keeps track of wrapper classes around native tags.
20
+ // This registry keeps track of wrapper classes around host tags.
21
21
  var tagToComponentClass = {};
22
22
  var textComponentClass = null;
23
23
 
24
- var ReactNativeComponentInjection = {
24
+ var ReactHostComponentInjection = {
25
25
  // This accepts a class that receives the tag string. This is a catch all
26
26
  // that can render any kind of tag.
27
27
  injectGenericComponentClass: function (componentClass) {
@@ -40,31 +40,13 @@ var ReactNativeComponentInjection = {
40
40
  };
41
41
 
42
42
  /**
43
- * Get a composite component wrapper class for a specific tag.
44
- *
45
- * @param {ReactElement} element The tag for which to get the class.
46
- * @return {function} The React class constructor function.
47
- */
48
- function getComponentClassForElement(element) {
49
- if (typeof element.type === 'function') {
50
- return element.type;
51
- }
52
- var tag = element.type;
53
- var componentClass = tagToComponentClass[tag];
54
- if (componentClass == null) {
55
- tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
56
- }
57
- return componentClass;
58
- }
59
-
60
- /**
61
- * Get a native internal component class for a specific tag.
43
+ * Get a host internal component class for a specific tag.
62
44
  *
63
45
  * @param {ReactElement} element The element to create.
64
46
  * @return {function} The internal class constructor function.
65
47
  */
66
48
  function createInternalComponent(element) {
67
- !genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : void 0;
49
+ !genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : _prodInvariant('111', element.type) : void 0;
68
50
  return new genericComponentClass(element);
69
51
  }
70
52
 
@@ -84,12 +66,11 @@ function isTextComponent(component) {
84
66
  return component instanceof textComponentClass;
85
67
  }
86
68
 
87
- var ReactNativeComponent = {
88
- getComponentClassForElement: getComponentClassForElement,
69
+ var ReactHostComponent = {
89
70
  createInternalComponent: createInternalComponent,
90
71
  createInstanceForText: createInstanceForText,
91
72
  isTextComponent: isTextComponent,
92
- injection: ReactNativeComponentInjection
73
+ injection: ReactHostComponentInjection
93
74
  };
94
75
 
95
- module.exports = ReactNativeComponent;
76
+ module.exports = ReactHostComponent;
@@ -0,0 +1,37 @@
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 ReactHostOperationHistoryDevtool
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var history = [];
15
+
16
+ var ReactHostOperationHistoryDevtool = {
17
+ onHostOperation: function (debugID, type, payload) {
18
+ history.push({
19
+ instanceID: debugID,
20
+ type: type,
21
+ payload: payload
22
+ });
23
+ },
24
+ clearHistory: function () {
25
+ if (ReactHostOperationHistoryDevtool._preventClearing) {
26
+ // Should only be used for tests.
27
+ return;
28
+ }
29
+
30
+ history = [];
31
+ },
32
+ getHistory: function () {
33
+ return history;
34
+ }
35
+ };
36
+
37
+ module.exports = ReactHostOperationHistoryDevtool;
@@ -18,8 +18,7 @@ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
18
18
  var ReactClass = require('./ReactClass');
19
19
  var ReactEmptyComponent = require('./ReactEmptyComponent');
20
20
  var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
21
- var ReactNativeComponent = require('./ReactNativeComponent');
22
- var ReactPerf = require('./ReactPerf');
21
+ var ReactHostComponent = require('./ReactHostComponent');
23
22
  var ReactUpdates = require('./ReactUpdates');
24
23
 
25
24
  var ReactInjection = {
@@ -30,8 +29,7 @@ var ReactInjection = {
30
29
  EventPluginHub: EventPluginHub.injection,
31
30
  EventPluginUtils: EventPluginUtils.injection,
32
31
  EventEmitter: ReactBrowserEventEmitter.injection,
33
- NativeComponent: ReactNativeComponent.injection,
34
- Perf: ReactPerf.injection,
32
+ HostComponent: ReactHostComponent.injection,
35
33
  Updates: ReactUpdates.injection
36
34
  };
37
35
 
@@ -11,6 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var invariant = require('fbjs/lib/invariant');
15
17
 
16
18
  var SEPARATOR = '.';
@@ -88,8 +90,8 @@ function getParentID(id) {
88
90
  * @private
89
91
  */
90
92
  function getNextDescendantID(ancestorID, destinationID) {
91
- !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : void 0;
92
- !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : void 0;
93
+ !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : _prodInvariant('112', ancestorID, destinationID) : void 0;
94
+ !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : _prodInvariant('113', ancestorID, destinationID) : void 0;
93
95
  if (ancestorID === destinationID) {
94
96
  return ancestorID;
95
97
  }
@@ -131,7 +133,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
131
133
  }
132
134
  }
133
135
  var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
134
- !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : void 0;
136
+ !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : _prodInvariant('114', oneID, twoID, longestCommonID) : void 0;
135
137
  return longestCommonID;
136
138
  }
137
139
 
@@ -151,9 +153,9 @@ function getFirstCommonAncestorID(oneID, twoID) {
151
153
  function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
152
154
  start = start || '';
153
155
  stop = stop || '';
154
- !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : void 0;
156
+ !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : _prodInvariant('115', start) : void 0;
155
157
  var traverseUp = isAncestorIDOf(stop, start);
156
- !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : void 0;
158
+ !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do not have a parent path.', start, stop) : _prodInvariant('116', start, stop) : void 0;
157
159
  // Traverse from `start` to `stop` one depth at a time.
158
160
  var depth = 0;
159
161
  var traverse = traverseUp ? getParentID : getNextDescendantID;
@@ -166,7 +168,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
166
168
  // Only break //after// visiting `stop`.
167
169
  break;
168
170
  }
169
- !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : void 0;
171
+ !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : _prodInvariant('117', start, stop, id) : void 0;
170
172
  }
171
173
  }
172
174
 
package/lib/ReactLink.js CHANGED
@@ -37,6 +37,9 @@
37
37
  var React = require('./React');
38
38
 
39
39
  /**
40
+ * Deprecated: An an easy way to express two-way binding with React.
41
+ * See https://facebook.github.io/react/docs/two-way-binding-helpers.html
42
+ *
40
43
  * @param {*} value current value of the link
41
44
  * @param {function} requestChange callback to request a change
42
45
  */
package/lib/ReactMount.js CHANGED
@@ -11,6 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var DOMLazyTree = require('./DOMLazyTree');
15
17
  var DOMProperty = require('./DOMProperty');
16
18
  var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
@@ -22,7 +24,6 @@ var ReactElement = require('./ReactElement');
22
24
  var ReactFeatureFlags = require('./ReactFeatureFlags');
23
25
  var ReactInstrumentation = require('./ReactInstrumentation');
24
26
  var ReactMarkupChecksum = require('./ReactMarkupChecksum');
25
- var ReactPerf = require('./ReactPerf');
26
27
  var ReactReconciler = require('./ReactReconciler');
27
28
  var ReactUpdateQueue = require('./ReactUpdateQueue');
28
29
  var ReactUpdates = require('./ReactUpdates');
@@ -135,7 +136,13 @@ function batchedMountComponentIntoNode(componentInstance, container, shouldReuse
135
136
  * @see {ReactMount.unmountComponentAtNode}
136
137
  */
137
138
  function unmountComponentFromNode(instance, container, safely) {
139
+ if (process.env.NODE_ENV !== 'production') {
140
+ ReactInstrumentation.debugTool.onBeginFlush();
141
+ }
138
142
  ReactReconciler.unmountComponent(instance, safely);
143
+ if (process.env.NODE_ENV !== 'production') {
144
+ ReactInstrumentation.debugTool.onEndFlush();
145
+ }
139
146
 
140
147
  if (container.nodeType === DOC_NODE_TYPE) {
141
148
  container = container.documentElement;
@@ -161,19 +168,19 @@ function hasNonRootReactChild(container) {
161
168
  var rootEl = getReactRootElementInContainer(container);
162
169
  if (rootEl) {
163
170
  var inst = ReactDOMComponentTree.getInstanceFromNode(rootEl);
164
- return !!(inst && inst._nativeParent);
171
+ return !!(inst && inst._hostParent);
165
172
  }
166
173
  }
167
174
 
168
- function getNativeRootInstanceInContainer(container) {
175
+ function getHostRootInstanceInContainer(container) {
169
176
  var rootEl = getReactRootElementInContainer(container);
170
- var prevNativeInstance = rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl);
171
- return prevNativeInstance && !prevNativeInstance._nativeParent ? prevNativeInstance : null;
177
+ var prevHostInstance = rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl);
178
+ return prevHostInstance && !prevHostInstance._hostParent ? prevHostInstance : null;
172
179
  }
173
180
 
174
181
  function getTopLevelWrapperInContainer(container) {
175
- var root = getNativeRootInstanceInContainer(container);
176
- return root ? root._nativeContainerInfo._topLevelWrapper : null;
182
+ var root = getHostRootInstanceInContainer(container);
183
+ return root ? root._hostContainerInfo._topLevelWrapper : null;
177
184
  }
178
185
 
179
186
  /**
@@ -260,16 +267,26 @@ var ReactMount = {
260
267
  * @return {ReactComponent} nextComponent
261
268
  */
262
269
  _renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) {
270
+ if (process.env.NODE_ENV !== 'production') {
271
+ ReactInstrumentation.debugTool.onBeginFlush();
272
+ }
273
+
263
274
  // Various parts of our code (such as ReactCompositeComponent's
264
275
  // _renderValidatedComponent) assume that calls to render aren't nested;
265
276
  // verify that that's the case.
266
277
  process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : void 0;
267
278
 
268
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : void 0;
279
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : _prodInvariant('37') : void 0;
269
280
 
270
281
  ReactBrowserEventEmitter.ensureScrollValueMonitoring();
271
282
  var componentInstance = instantiateReactComponent(nextElement);
272
283
 
284
+ if (process.env.NODE_ENV !== 'production') {
285
+ // Mute future events from the top level wrapper.
286
+ // It is an implementation detail that devtools should not know about.
287
+ componentInstance._debugID = 0;
288
+ }
289
+
273
290
  // The initial render is synchronous but any updates that happen during
274
291
  // rendering, in componentWillMount or componentDidMount, will be batched
275
292
  // according to the current batching strategy.
@@ -280,7 +297,9 @@ var ReactMount = {
280
297
  instancesByReactRootID[wrapperID] = componentInstance;
281
298
 
282
299
  if (process.env.NODE_ENV !== 'production') {
283
- ReactInstrumentation.debugTool.onMountRootComponent(componentInstance);
300
+ // The instance here is TopLevelWrapper so we report mount for its child.
301
+ ReactInstrumentation.debugTool.onMountRootComponent(componentInstance._renderedComponent._debugID);
302
+ ReactInstrumentation.debugTool.onEndFlush();
284
303
  }
285
304
 
286
305
  return componentInstance;
@@ -300,7 +319,7 @@ var ReactMount = {
300
319
  * @return {ReactComponent} Component instance rendered in `container`.
301
320
  */
302
321
  renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
303
- !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : void 0;
322
+ !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : _prodInvariant('38') : void 0;
304
323
  return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
305
324
  },
306
325
 
@@ -308,7 +327,7 @@ var ReactMount = {
308
327
  ReactUpdateQueue.validateCallback(callback, 'ReactDOM.render');
309
328
  !ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' :
310
329
  // Check if it quacks like an element
311
- nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : void 0;
330
+ nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : _prodInvariant('39', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' : nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : void 0;
312
331
 
313
332
  process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : void 0;
314
333
 
@@ -360,6 +379,7 @@ var ReactMount = {
360
379
 
361
380
  /**
362
381
  * Renders a React component into the DOM in the supplied `container`.
382
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.render
363
383
  *
364
384
  * If the React component was previously rendered into `container`, this will
365
385
  * perform an update on it and only mutate the DOM as necessary to reflect the
@@ -376,6 +396,7 @@ var ReactMount = {
376
396
 
377
397
  /**
378
398
  * Unmounts and destroys the React component rendered in the `container`.
399
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode
379
400
  *
380
401
  * @param {DOMElement} container DOM element containing a React component.
381
402
  * @return {boolean} True if a component was found in and unmounted from
@@ -388,7 +409,7 @@ var ReactMount = {
388
409
  // render but we still don't expect to be in a render call here.)
389
410
  process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : void 0;
390
411
 
391
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : void 0;
412
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : _prodInvariant('40') : void 0;
392
413
 
393
414
  var prevComponent = getTopLevelWrapperInContainer(container);
394
415
  if (!prevComponent) {
@@ -411,7 +432,7 @@ var ReactMount = {
411
432
  },
412
433
 
413
434
  _mountImageIntoNode: function (markup, container, instance, shouldReuseMarkup, transaction) {
414
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : void 0;
435
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : _prodInvariant('41') : void 0;
415
436
 
416
437
  if (shouldReuseMarkup) {
417
438
  var rootElement = getReactRootElementInContainer(container);
@@ -448,7 +469,7 @@ var ReactMount = {
448
469
  var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
449
470
  var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
450
471
 
451
- !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference) : invariant(false) : void 0;
472
+ !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side:\n%s', difference) : _prodInvariant('42', difference) : void 0;
452
473
 
453
474
  if (process.env.NODE_ENV !== 'production') {
454
475
  process.env.NODE_ENV !== 'production' ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : void 0;
@@ -456,7 +477,7 @@ var ReactMount = {
456
477
  }
457
478
  }
458
479
 
459
- !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See ReactDOMServer.renderToString() for server rendering.') : invariant(false) : void 0;
480
+ !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but you didn\'t use server rendering. We can\'t do this without using server rendering due to cross-browser quirks. See ReactDOMServer.renderToString() for server rendering.') : _prodInvariant('43') : void 0;
460
481
 
461
482
  if (transaction.useCreateElement) {
462
483
  while (container.lastChild) {
@@ -467,12 +488,14 @@ var ReactMount = {
467
488
  setInnerHTML(container, markup);
468
489
  ReactDOMComponentTree.precacheNode(instance, container.firstChild);
469
490
  }
491
+
492
+ if (process.env.NODE_ENV !== 'production') {
493
+ var hostNode = ReactDOMComponentTree.getInstanceFromNode(container.firstChild);
494
+ if (hostNode._debugID !== 0) {
495
+ ReactInstrumentation.debugTool.onHostOperation(hostNode._debugID, 'mount', markup.toString());
496
+ }
497
+ }
470
498
  }
471
499
  };
472
500
 
473
- ReactPerf.measureMethods(ReactMount, 'ReactMount', {
474
- _renderNewRootComponent: '_renderNewRootComponent',
475
- _mountImageIntoNode: '_mountImageIntoNode'
476
- });
477
-
478
501
  module.exports = ReactMount;