react 15.0.3-alpha.1 → 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 (122) hide show
  1. package/dist/react-with-addons.js +3311 -2007
  2. package/dist/react-with-addons.min.js +7 -6
  3. package/dist/react.js +2734 -2014
  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 +18 -5
  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 +165 -71
  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 +57 -19
  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 +41 -15
  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/ReactServerRenderingTransaction.js +5 -1
  82. package/lib/ReactSimpleEmptyComponent.js +4 -4
  83. package/lib/ReactTestMount.js +126 -0
  84. package/lib/ReactTestReconcileTransaction.js +100 -0
  85. package/lib/ReactTestRenderer.js +133 -0
  86. package/lib/ReactTestUtils.js +25 -10
  87. package/lib/ReactTransitionChildMapping.js +7 -1
  88. package/lib/ReactTransitionGroup.js +44 -5
  89. package/lib/ReactUpdateQueue.js +9 -1
  90. package/lib/ReactUpdates.js +30 -11
  91. package/lib/ReactVersion.js +1 -1
  92. package/lib/ReactWithAddons.js +1 -1
  93. package/lib/ResponderEventPlugin.js +8 -6
  94. package/lib/ResponderTouchHistoryStore.js +6 -4
  95. package/lib/SimpleEventPlugin.js +3 -1
  96. package/lib/SyntheticEvent.js +2 -3
  97. package/lib/SyntheticUIEvent.js +1 -1
  98. package/lib/Transaction.js +4 -2
  99. package/lib/accumulate.js +3 -1
  100. package/lib/accumulateInto.js +3 -1
  101. package/lib/checkReactTypeSpec.js +71 -0
  102. package/lib/createReactNativeComponentClass.js +2 -2
  103. package/lib/dangerousStyleValue.js +3 -1
  104. package/lib/escapeTextContentForBrowser.js +96 -12
  105. package/lib/findDOMNode.js +8 -4
  106. package/lib/findNodeHandle.js +5 -3
  107. package/lib/flattenChildren.js +13 -4
  108. package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
  109. package/lib/instantiateReactComponent.js +44 -10
  110. package/lib/onlyChild.js +10 -5
  111. package/lib/reactComponentExpect.js +3 -3
  112. package/lib/reactProdInvariant.js +38 -0
  113. package/lib/setInnerHTML.js +17 -1
  114. package/lib/setTextContent.js +8 -0
  115. package/lib/shallowCompare.js +1 -0
  116. package/lib/traverseAllChildren.js +3 -1
  117. package/lib/update.js +16 -11
  118. package/package.json +2 -2
  119. package/lib/MetaMatchers.js +0 -118
  120. package/lib/ReactDebugInstanceMap.js +0 -102
  121. package/lib/ReactDefaultPerf.js +0 -316
  122. package/lib/ReactDefaultPerfAnalysis.js +0 -210
@@ -11,17 +11,21 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var ReactCurrentOwner = require('./ReactCurrentOwner');
15
17
  var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
18
  var ReactInstanceMap = require('./ReactInstanceMap');
17
19
 
18
- var getNativeComponentFromComposite = require('./getNativeComponentFromComposite');
20
+ var getHostComponentFromComposite = require('./getHostComponentFromComposite');
19
21
  var invariant = require('fbjs/lib/invariant');
20
22
  var warning = require('fbjs/lib/warning');
21
23
 
22
24
  /**
23
25
  * Returns the DOM node rendered by this element.
24
26
  *
27
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode
28
+ *
25
29
  * @param {ReactComponent|DOMElement} componentOrElement
26
30
  * @return {?DOMElement} The root node of this element.
27
31
  */
@@ -42,14 +46,14 @@ function findDOMNode(componentOrElement) {
42
46
 
43
47
  var inst = ReactInstanceMap.get(componentOrElement);
44
48
  if (inst) {
45
- inst = getNativeComponentFromComposite(inst);
49
+ inst = getHostComponentFromComposite(inst);
46
50
  return inst ? ReactDOMComponentTree.getNodeFromInstance(inst) : null;
47
51
  }
48
52
 
49
53
  if (typeof componentOrElement.render === 'function') {
50
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) : void 0;
54
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : _prodInvariant('44') : void 0;
51
55
  } else {
52
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) : void 0;
56
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : _prodInvariant('45', Object.keys(componentOrElement)) : void 0;
53
57
  }
54
58
  }
55
59
 
@@ -12,6 +12,8 @@
12
12
 
13
13
  'use strict';
14
14
 
15
+ var _prodInvariant = require('./reactProdInvariant');
16
+
15
17
  var ReactCurrentOwner = require('./ReactCurrentOwner');
16
18
  var ReactInstanceMap = require('./ReactInstanceMap');
17
19
 
@@ -70,7 +72,7 @@ function findNodeHandle(componentOrHandle) {
70
72
  // ReactInstanceMap.get here will always succeed for mounted components
71
73
  var internalInstance = ReactInstanceMap.get(component);
72
74
  if (internalInstance) {
73
- return internalInstance.getNativeNode();
75
+ return internalInstance.getHostNode();
74
76
  } else {
75
77
  var rootNodeID = component._rootNodeID;
76
78
  if (rootNodeID) {
@@ -80,8 +82,8 @@ function findNodeHandle(componentOrHandle) {
80
82
  // Native
81
83
  typeof component === 'object' && '_rootNodeID' in component ||
82
84
  // Composite
83
- component.render != null && typeof component.render === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Argument is not a component ' + '(type: %s, keys: %s)', typeof component, Object.keys(component)) : invariant(false) : void 0;
84
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Unable to find node handle for unmounted ' + 'component.') : invariant(false) : void 0;
85
+ component.render != null && typeof component.render === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Argument is not a component (type: %s, keys: %s)', typeof component, Object.keys(component)) : _prodInvariant('21', typeof component, Object.keys(component)) : void 0;
86
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Unable to find node handle for unmounted component.') : _prodInvariant('22') : void 0;
85
87
  }
86
88
  }
87
89
  }
@@ -11,6 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
14
15
  var KeyEscapeUtils = require('./KeyEscapeUtils');
15
16
  var traverseAllChildren = require('./traverseAllChildren');
16
17
  var warning = require('fbjs/lib/warning');
@@ -19,13 +20,14 @@ var warning = require('fbjs/lib/warning');
19
20
  * @param {function} traverseContext Context passed through traversal.
20
21
  * @param {?ReactComponent} child React child component.
21
22
  * @param {!string} name String name of key path to child.
23
+ * @param {number=} selfDebugID Optional debugID of the current internal instance.
22
24
  */
23
- function flattenSingleChildIntoContext(traverseContext, child, name) {
25
+ function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID) {
24
26
  // We found a component instance.
25
27
  var result = traverseContext;
26
28
  var keyUnique = result[name] === undefined;
27
29
  if (process.env.NODE_ENV !== 'production') {
28
- process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', KeyEscapeUtils.unescape(name)) : void 0;
30
+ process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeDevtool.getStackAddendumByID(selfDebugID)) : void 0;
29
31
  }
30
32
  if (keyUnique && child != null) {
31
33
  result[name] = child;
@@ -37,12 +39,19 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
37
39
  * children will not be included in the resulting object.
38
40
  * @return {!object} flattened children keyed by name.
39
41
  */
40
- function flattenChildren(children) {
42
+ function flattenChildren(children, selfDebugID) {
41
43
  if (children == null) {
42
44
  return children;
43
45
  }
44
46
  var result = {};
45
- traverseAllChildren(children, flattenSingleChildIntoContext, result);
47
+
48
+ if (process.env.NODE_ENV !== 'production') {
49
+ traverseAllChildren(children, function (traverseContext, child, name) {
50
+ return flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID);
51
+ }, result);
52
+ } else {
53
+ traverseAllChildren(children, flattenSingleChildIntoContext, result);
54
+ }
46
55
  return result;
47
56
  }
48
57
 
@@ -6,25 +6,25 @@
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 getNativeComponentFromComposite
9
+ * @providesModule getHostComponentFromComposite
10
10
  */
11
11
 
12
12
  'use strict';
13
13
 
14
14
  var ReactNodeTypes = require('./ReactNodeTypes');
15
15
 
16
- function getNativeComponentFromComposite(inst) {
16
+ function getHostComponentFromComposite(inst) {
17
17
  var type;
18
18
 
19
19
  while ((type = inst._renderedNodeType) === ReactNodeTypes.COMPOSITE) {
20
20
  inst = inst._renderedComponent;
21
21
  }
22
22
 
23
- if (type === ReactNodeTypes.NATIVE) {
23
+ if (type === ReactNodeTypes.HOST) {
24
24
  return inst._renderedComponent;
25
25
  } else if (type === ReactNodeTypes.EMPTY) {
26
26
  return null;
27
27
  }
28
28
  }
29
29
 
30
- module.exports = getNativeComponentFromComposite;
30
+ module.exports = getHostComponentFromComposite;
@@ -11,11 +11,13 @@
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 ReactCompositeComponent = require('./ReactCompositeComponent');
17
18
  var ReactEmptyComponent = require('./ReactEmptyComponent');
18
- var ReactNativeComponent = require('./ReactNativeComponent');
19
+ var ReactHostComponent = require('./ReactHostComponent');
20
+ var ReactInstrumentation = require('./ReactInstrumentation');
19
21
 
20
22
  var invariant = require('fbjs/lib/invariant');
21
23
  var warning = require('fbjs/lib/warning');
@@ -38,6 +40,21 @@ function getDeclarationErrorAddendum(owner) {
38
40
  return '';
39
41
  }
40
42
 
43
+ function getDisplayName(instance) {
44
+ var element = instance._currentElement;
45
+ if (element == null) {
46
+ return '#empty';
47
+ } else if (typeof element === 'string' || typeof element === 'number') {
48
+ return '#text';
49
+ } else if (typeof element.type === 'string') {
50
+ return element.type;
51
+ } else if (instance.getName) {
52
+ return instance.getName() || 'Unknown';
53
+ } else {
54
+ return element.type.displayName || element.type.name || 'Unknown';
55
+ }
56
+ }
57
+
41
58
  /**
42
59
  * Check if the type reference is a known internal type. I.e. not a user
43
60
  * provided composite type.
@@ -49,6 +66,8 @@ function isInternalComponentType(type) {
49
66
  return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
50
67
  }
51
68
 
69
+ var nextDebugID = 1;
70
+
52
71
  /**
53
72
  * Given a ReactNode, create an instance that will actually be mounted.
54
73
  *
@@ -59,31 +78,37 @@ function isInternalComponentType(type) {
59
78
  function instantiateReactComponent(node) {
60
79
  var instance;
61
80
 
62
- if (node === null || node === false) {
81
+ var isEmpty = node === null || node === false;
82
+ if (isEmpty) {
63
83
  instance = ReactEmptyComponent.create(instantiateReactComponent);
64
84
  } else if (typeof node === 'object') {
65
85
  var element = node;
66
- !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : void 0;
86
+ !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : _prodInvariant('130', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : void 0;
67
87
 
68
88
  // Special case string values
69
89
  if (typeof element.type === 'string') {
70
- instance = ReactNativeComponent.createInternalComponent(element);
90
+ instance = ReactHostComponent.createInternalComponent(element);
71
91
  } else if (isInternalComponentType(element.type)) {
72
92
  // This is temporarily available for custom components that are not string
73
93
  // representations. I.e. ART. Once those are updated to use the string
74
94
  // representation, we can drop this code path.
75
95
  instance = new element.type(element);
96
+
97
+ // We renamed this. Allow the old name for compat. :(
98
+ if (!instance.getHostNode) {
99
+ instance.getHostNode = instance.getNativeNode;
100
+ }
76
101
  } else {
77
102
  instance = new ReactCompositeComponentWrapper(element);
78
103
  }
79
104
  } else if (typeof node === 'string' || typeof node === 'number') {
80
- instance = ReactNativeComponent.createInstanceForText(node);
105
+ instance = ReactHostComponent.createInstanceForText(node);
81
106
  } else {
82
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : void 0;
107
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : _prodInvariant('131', typeof node) : void 0;
83
108
  }
84
109
 
85
110
  if (process.env.NODE_ENV !== 'production') {
86
- process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getNativeNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
111
+ process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getHostNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
87
112
  }
88
113
 
89
114
  // These two fields are used by the DOM and ART diffing algorithms
@@ -93,8 +118,17 @@ function instantiateReactComponent(node) {
93
118
  instance._mountImage = null;
94
119
 
95
120
  if (process.env.NODE_ENV !== 'production') {
96
- instance._isOwnerNecessary = false;
97
- instance._warnedAboutRefsInRender = false;
121
+ var debugID = isEmpty ? 0 : nextDebugID++;
122
+ instance._debugID = debugID;
123
+
124
+ if (debugID !== 0) {
125
+ var displayName = getDisplayName(instance);
126
+ ReactInstrumentation.debugTool.onSetDisplayName(debugID, displayName);
127
+ var owner = node && node._owner;
128
+ if (owner) {
129
+ ReactInstrumentation.debugTool.onSetOwner(debugID, owner._debugID);
130
+ }
131
+ }
98
132
  }
99
133
 
100
134
  // Internal instances should fully constructed at this point, so they should
package/lib/onlyChild.js CHANGED
@@ -10,23 +10,28 @@
10
10
  */
11
11
  'use strict';
12
12
 
13
+ var _prodInvariant = require('./reactProdInvariant');
14
+
13
15
  var ReactElement = require('./ReactElement');
14
16
 
15
17
  var invariant = require('fbjs/lib/invariant');
16
18
 
17
19
  /**
18
20
  * Returns the first child in a collection of children and verifies that there
19
- * is only one child in the collection. The current implementation of this
20
- * function assumes that a single child gets passed without a wrapper, but the
21
- * purpose of this helper function is to abstract away the particular structure
22
- * of children.
21
+ * is only one child in the collection.
22
+ *
23
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.only
24
+ *
25
+ * The current implementation of this function assumes that a single child gets
26
+ * passed without a wrapper, but the purpose of this helper function is to
27
+ * abstract away the particular structure of children.
23
28
  *
24
29
  * @param {?object} children Child collection structure.
25
30
  * @return {ReactElement} The first and only `ReactElement` contained in the
26
31
  * structure.
27
32
  */
28
33
  function onlyChild(children) {
29
- !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : void 0;
34
+ !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : _prodInvariant('23') : void 0;
30
35
  return children;
31
36
  }
32
37
 
@@ -7,12 +7,12 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule reactComponentExpect
10
- * @nolint
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
15
- var _assign = require('object-assign');
14
+ var _prodInvariant = require('./reactProdInvariant'),
15
+ _assign = require('object-assign');
16
16
 
17
17
  var ReactInstanceMap = require('./ReactInstanceMap');
18
18
  var ReactTestUtils = require('./ReactTestUtils');
@@ -31,7 +31,7 @@ function reactComponentExpect(instance) {
31
31
  expect(instance).not.toBeNull();
32
32
  expect(instance).not.toBeUndefined();
33
33
 
34
- !ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : invariant(false) : void 0;
34
+ !ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : _prodInvariant('15') : void 0;
35
35
  var internalInstance = ReactInstanceMap.get(instance);
36
36
 
37
37
  expect(typeof internalInstance).toBe('object');
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule reactProdInvariant
10
+ */
11
+ 'use strict';
12
+
13
+ /**
14
+ * WARNING: DO NOT manually require this module.
15
+ * This is a replacement for `invariant(...)` used by the error code system
16
+ * and will _only_ be required by the corresponding babel pass.
17
+ * It always throws.
18
+ */
19
+
20
+ function reactProdInvariant(code) {
21
+ var argCount = arguments.length - 1;
22
+
23
+ var message = 'Minified React error #' + code + '; visit ' + 'http://facebook.github.io/react/docs/error-decoder.html?invariant=' + code;
24
+
25
+ for (var argIdx = 0; argIdx < argCount; argIdx++) {
26
+ message += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
27
+ }
28
+
29
+ message += ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.';
30
+
31
+ var error = new Error(message);
32
+ error.name = 'Invariant Violation';
33
+ error.framesToPop = 1; // we don't care about reactProdInvariant's own frame
34
+
35
+ throw error;
36
+ }
37
+
38
+ module.exports = reactProdInvariant;
@@ -12,12 +12,16 @@
12
12
  'use strict';
13
13
 
14
14
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
+ var DOMNamespaces = require('./DOMNamespaces');
15
16
 
16
17
  var WHITESPACE_TEST = /^[ \r\n\t\f]/;
17
18
  var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
18
19
 
19
20
  var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
20
21
 
22
+ // SVG temp container for IE lacking innerHTML
23
+ var reusableSVGContainer;
24
+
21
25
  /**
22
26
  * Set the innerHTML property of a node, ensuring that whitespace is preserved
23
27
  * even in IE8.
@@ -27,7 +31,19 @@ var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFu
27
31
  * @internal
28
32
  */
29
33
  var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
30
- node.innerHTML = html;
34
+ // IE does not have innerHTML for SVG nodes, so instead we inject the
35
+ // new markup in a temp node and then move the child nodes across into
36
+ // the target node
37
+ if (node.namespaceURI === DOMNamespaces.svg && !('innerHTML' in node)) {
38
+ reusableSVGContainer = reusableSVGContainer || document.createElement('div');
39
+ reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
40
+ var newNodes = reusableSVGContainer.firstChild.childNodes;
41
+ for (var i = 0; i < newNodes.length; i++) {
42
+ node.appendChild(newNodes[i]);
43
+ }
44
+ } else {
45
+ node.innerHTML = html;
46
+ }
31
47
  });
32
48
 
33
49
  if (ExecutionEnvironment.canUseDOM) {
@@ -26,6 +26,14 @@ var setInnerHTML = require('./setInnerHTML');
26
26
  * @internal
27
27
  */
28
28
  var setTextContent = function (node, text) {
29
+ if (text) {
30
+ var firstChild = node.firstChild;
31
+
32
+ if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) {
33
+ firstChild.nodeValue = text;
34
+ return;
35
+ }
36
+ }
29
37
  node.textContent = text;
30
38
  };
31
39
 
@@ -16,6 +16,7 @@ var shallowEqual = require('fbjs/lib/shallowEqual');
16
16
  /**
17
17
  * Does a shallow comparison for props and state.
18
18
  * See ReactComponentWithPureRenderMixin
19
+ * See also https://facebook.github.io/react/docs/shallow-compare.html
19
20
  */
20
21
  function shallowCompare(instance, nextProps, nextState) {
21
22
  return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
@@ -11,6 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var ReactCurrentOwner = require('./ReactCurrentOwner');
15
17
  var ReactElement = require('./ReactElement');
16
18
 
@@ -124,7 +126,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
124
126
  }
125
127
  }
126
128
  var childrenString = String(children);
127
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) : void 0;
129
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : _prodInvariant('31', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : void 0;
128
130
  }
129
131
  }
130
132
 
package/lib/update.js CHANGED
@@ -13,7 +13,8 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- var _assign = require('object-assign');
16
+ var _prodInvariant = require('./reactProdInvariant'),
17
+ _assign = require('object-assign');
17
18
 
18
19
  var keyOf = require('fbjs/lib/keyOf');
19
20
  var invariant = require('fbjs/lib/invariant');
@@ -45,16 +46,20 @@ ALL_COMMANDS_LIST.forEach(function (command) {
45
46
  });
46
47
 
47
48
  function invariantArrayCase(value, spec, command) {
48
- !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected target of %s to be an array; got %s.', command, value) : invariant(false) : void 0;
49
+ !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected target of %s to be an array; got %s.', command, value) : _prodInvariant('1', command, value) : void 0;
49
50
  var specValue = spec[command];
50
- !Array.isArray(specValue) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array; got %s. ' + 'Did you forget to wrap your parameter in an array?', command, specValue) : invariant(false) : void 0;
51
+ !Array.isArray(specValue) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array; got %s. Did you forget to wrap your parameter in an array?', command, specValue) : _prodInvariant('2', command, specValue) : void 0;
51
52
  }
52
53
 
54
+ /**
55
+ * Returns a updated shallow copy of an object without mutating the original.
56
+ * See https://facebook.github.io/react/docs/update.html for details.
57
+ */
53
58
  function update(value, spec) {
54
- !(typeof spec === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): You provided a key path to update() that did not contain one ' + 'of %s. Did you forget to include {%s: ...}?', ALL_COMMANDS_LIST.join(', '), COMMAND_SET) : invariant(false) : void 0;
59
+ !(typeof spec === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): You provided a key path to update() that did not contain one of %s. Did you forget to include {%s: ...}?', ALL_COMMANDS_LIST.join(', '), COMMAND_SET) : _prodInvariant('3', ALL_COMMANDS_LIST.join(', '), COMMAND_SET) : void 0;
55
60
 
56
61
  if (hasOwnProperty.call(spec, COMMAND_SET)) {
57
- !(Object.keys(spec).length === 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot have more than one key in an object with %s', COMMAND_SET) : invariant(false) : void 0;
62
+ !(Object.keys(spec).length === 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot have more than one key in an object with %s', COMMAND_SET) : _prodInvariant('4', COMMAND_SET) : void 0;
58
63
 
59
64
  return spec[COMMAND_SET];
60
65
  }
@@ -63,8 +68,8 @@ function update(value, spec) {
63
68
 
64
69
  if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
65
70
  var mergeObj = spec[COMMAND_MERGE];
66
- !(mergeObj && typeof mergeObj === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a spec of type \'object\'; got %s', COMMAND_MERGE, mergeObj) : invariant(false) : void 0;
67
- !(nextValue && typeof nextValue === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a target of type \'object\'; got %s', COMMAND_MERGE, nextValue) : invariant(false) : void 0;
71
+ !(mergeObj && typeof mergeObj === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a spec of type \'object\'; got %s', COMMAND_MERGE, mergeObj) : _prodInvariant('5', COMMAND_MERGE, mergeObj) : void 0;
72
+ !(nextValue && typeof nextValue === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a target of type \'object\'; got %s', COMMAND_MERGE, nextValue) : _prodInvariant('6', COMMAND_MERGE, nextValue) : void 0;
68
73
  _assign(nextValue, spec[COMMAND_MERGE]);
69
74
  }
70
75
 
@@ -83,16 +88,16 @@ function update(value, spec) {
83
88
  }
84
89
 
85
90
  if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
86
- !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s target to be an array; got %s', COMMAND_SPLICE, value) : invariant(false) : void 0;
87
- !Array.isArray(spec[COMMAND_SPLICE]) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. ' + 'Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : invariant(false) : void 0;
91
+ !Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s target to be an array; got %s', COMMAND_SPLICE, value) : _prodInvariant('7', COMMAND_SPLICE, value) : void 0;
92
+ !Array.isArray(spec[COMMAND_SPLICE]) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : _prodInvariant('8', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : void 0;
88
93
  spec[COMMAND_SPLICE].forEach(function (args) {
89
- !Array.isArray(args) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. ' + 'Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : invariant(false) : void 0;
94
+ !Array.isArray(args) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : _prodInvariant('8', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : void 0;
90
95
  nextValue.splice.apply(nextValue, args);
91
96
  });
92
97
  }
93
98
 
94
99
  if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
95
- !(typeof spec[COMMAND_APPLY] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be a function; got %s.', COMMAND_APPLY, spec[COMMAND_APPLY]) : invariant(false) : void 0;
100
+ !(typeof spec[COMMAND_APPLY] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be a function; got %s.', COMMAND_APPLY, spec[COMMAND_APPLY]) : _prodInvariant('9', COMMAND_APPLY, spec[COMMAND_APPLY]) : void 0;
96
101
  nextValue = spec[COMMAND_APPLY](nextValue);
97
102
  }
98
103