react 15.1.0 → 15.2.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 (124) hide show
  1. package/dist/react-with-addons.js +2685 -1842
  2. package/dist/react-with-addons.min.js +6 -6
  3. package/dist/react.js +2400 -1691
  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 +5 -12
  10. package/lib/DOMPropertyOperations.js +21 -15
  11. package/lib/Danger.js +5 -101
  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/KeyEscapeUtils.js +2 -1
  18. package/lib/LinkedValueUtils.js +5 -3
  19. package/lib/NativeMethodsMixin.js +6 -4
  20. package/lib/PooledClass.js +4 -2
  21. package/lib/React.js +1 -1
  22. package/lib/ReactCSSTransitionGroupChild.js +15 -8
  23. package/lib/ReactChildReconciler.js +17 -8
  24. package/lib/ReactClass.js +14 -13
  25. package/lib/ReactComponent.js +3 -6
  26. package/lib/ReactComponentEnvironment.js +3 -1
  27. package/lib/ReactComponentTreeDevtool.js +89 -16
  28. package/lib/ReactComponentTreeTestUtils.js +87 -0
  29. package/lib/ReactCompositeComponent.js +87 -117
  30. package/lib/ReactDOM.js +2 -2
  31. package/lib/ReactDOMButton.js +2 -2
  32. package/lib/ReactDOMComponent.js +130 -76
  33. package/lib/ReactDOMComponentTree.js +23 -21
  34. package/lib/ReactDOMDebugTool.js +17 -11
  35. package/lib/ReactDOMEmptyComponent.js +9 -9
  36. package/lib/ReactDOMFactories.js +1 -1
  37. package/lib/ReactDOMFiber.js +78 -0
  38. package/lib/ReactDOMInput.js +64 -26
  39. package/lib/ReactDOMInstrumentation.js +7 -2
  40. package/lib/ReactDOMNullInputValuePropDevtool.js +43 -0
  41. package/lib/ReactDOMOption.js +40 -26
  42. package/lib/ReactDOMSelect.js +3 -16
  43. package/lib/ReactDOMTextComponent.js +21 -20
  44. package/lib/ReactDOMTextarea.js +59 -46
  45. package/lib/ReactDOMTreeTraversal.js +18 -16
  46. package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
  47. package/lib/ReactDebugTool.js +148 -95
  48. package/lib/ReactDefaultInjection.js +2 -2
  49. package/lib/ReactElement.js +64 -25
  50. package/lib/ReactElementValidator.js +26 -81
  51. package/lib/ReactEventListener.js +2 -2
  52. package/lib/ReactFeatureFlags.js +1 -0
  53. package/lib/ReactFragment.js +3 -1
  54. package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
  55. package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
  56. package/lib/ReactInjection.js +2 -2
  57. package/lib/ReactInstanceHandles.js +8 -6
  58. package/lib/ReactInstrumentation.js +7 -2
  59. package/lib/ReactMount.js +38 -32
  60. package/lib/ReactMultiChild.js +38 -11
  61. package/lib/ReactNativeAttributePayload.js +5 -2
  62. package/lib/ReactNativeBaseComponent.js +7 -7
  63. package/lib/ReactNativeBridgeEventPlugin.js +1 -1
  64. package/lib/ReactNativeComponentTree.js +8 -6
  65. package/lib/ReactNativeDOMIDOperations.js +1 -2
  66. package/lib/ReactNativeDefaultInjection.js +9 -7
  67. package/lib/ReactNativeGlobalResponderHandler.js +1 -1
  68. package/lib/ReactNativeMount.js +3 -14
  69. package/lib/ReactNativeReconcileTransaction.js +16 -0
  70. package/lib/ReactNativeTagHandles.js +3 -1
  71. package/lib/ReactNativeTextComponent.js +10 -9
  72. package/lib/ReactNativeTreeTraversal.js +11 -11
  73. package/lib/ReactNodeTypes.js +6 -3
  74. package/lib/ReactNoop.js +173 -0
  75. package/lib/ReactNoopUpdateQueue.js +6 -5
  76. package/lib/ReactOwner.js +4 -2
  77. package/lib/ReactPerf.js +83 -7
  78. package/lib/ReactPropTypes.js +23 -0
  79. package/lib/ReactReconcileTransaction.js +17 -1
  80. package/lib/ReactReconciler.js +12 -7
  81. package/lib/ReactServerRendering.js +5 -7
  82. package/lib/ReactServerRenderingTransaction.js +17 -0
  83. package/lib/ReactServerUpdateQueue.js +141 -0
  84. package/lib/ReactSimpleEmptyComponent.js +4 -4
  85. package/lib/ReactTestMount.js +115 -0
  86. package/lib/ReactTestReconcileTransaction.js +108 -0
  87. package/lib/ReactTestRenderer.js +133 -0
  88. package/lib/ReactTestUtils.js +17 -10
  89. package/lib/ReactTransitionChildMapping.js +7 -1
  90. package/lib/ReactTransitionGroup.js +41 -6
  91. package/lib/ReactUpdateQueue.js +13 -3
  92. package/lib/ReactUpdates.js +10 -18
  93. package/lib/ReactVersion.js +1 -1
  94. package/lib/ResponderEventPlugin.js +9 -7
  95. package/lib/ResponderTouchHistoryStore.js +99 -95
  96. package/lib/SimpleEventPlugin.js +3 -1
  97. package/lib/SyntheticEvent.js +2 -3
  98. package/lib/SyntheticUIEvent.js +1 -1
  99. package/lib/Transaction.js +4 -2
  100. package/lib/accumulate.js +17 -15
  101. package/lib/accumulateInto.js +11 -12
  102. package/lib/adler32.js +1 -0
  103. package/lib/checkReactTypeSpec.js +73 -0
  104. package/lib/createReactNativeComponentClass.js +2 -2
  105. package/lib/dangerousStyleValue.js +3 -1
  106. package/lib/deprecated.js +7 -1
  107. package/lib/escapeTextContentForBrowser.js +96 -12
  108. package/lib/findDOMNode.js +6 -4
  109. package/lib/findNodeHandle.js +5 -3
  110. package/lib/flattenChildren.js +22 -10
  111. package/lib/forEachAccumulated.js +3 -2
  112. package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
  113. package/lib/getIteratorFn.js +1 -0
  114. package/lib/instantiateReactComponent.js +21 -19
  115. package/lib/isTextInputElement.js +11 -1
  116. package/lib/onlyChild.js +3 -1
  117. package/lib/reactComponentExpect.js +3 -3
  118. package/lib/reactProdInvariant.js +39 -0
  119. package/lib/setInnerHTML.js +17 -1
  120. package/lib/setTextContent.js +8 -0
  121. package/lib/traverseAllChildren.js +3 -1
  122. package/lib/update.js +12 -11
  123. package/package.json +2 -2
  124. package/lib/MetaMatchers.js +0 -118
@@ -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
  }
@@ -7,6 +7,7 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule flattenChildren
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
@@ -19,16 +20,20 @@ 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
- var result = traverseContext;
26
- var keyUnique = result[name] === undefined;
27
- 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;
29
- }
30
- if (keyUnique && child != null) {
31
- result[name] = child;
27
+ if (traverseContext && typeof traverseContext === 'object') {
28
+ var result = traverseContext;
29
+ var keyUnique = result[name] === undefined;
30
+ if (process.env.NODE_ENV !== 'production') {
31
+ var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
32
+ 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;
33
+ }
34
+ if (keyUnique && child != null) {
35
+ result[name] = child;
36
+ }
32
37
  }
33
38
  }
34
39
 
@@ -37,12 +42,19 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
37
42
  * children will not be included in the resulting object.
38
43
  * @return {!object} flattened children keyed by name.
39
44
  */
40
- function flattenChildren(children) {
45
+ function flattenChildren(children, selfDebugID) {
41
46
  if (children == null) {
42
47
  return children;
43
48
  }
44
49
  var result = {};
45
- traverseAllChildren(children, flattenSingleChildIntoContext, result);
50
+
51
+ if (process.env.NODE_ENV !== 'production') {
52
+ traverseAllChildren(children, function (traverseContext, child, name) {
53
+ return flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID);
54
+ }, result);
55
+ } else {
56
+ traverseAllChildren(children, flattenSingleChildIntoContext, result);
57
+ }
46
58
  return result;
47
59
  }
48
60
 
@@ -7,6 +7,7 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule forEachAccumulated
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
@@ -19,12 +20,12 @@
19
20
  * allocate an array).
20
21
  */
21
22
 
22
- var forEachAccumulated = function (arr, cb, scope) {
23
+ function forEachAccumulated(arr, cb, scope) {
23
24
  if (Array.isArray(arr)) {
24
25
  arr.forEach(cb, scope);
25
26
  } else if (arr) {
26
27
  cb.call(scope, arr);
27
28
  }
28
- };
29
+ }
29
30
 
30
31
  module.exports = forEachAccumulated;
@@ -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;
@@ -7,6 +7,7 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule getIteratorFn
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
@@ -11,11 +11,12 @@
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');
19
20
  var ReactInstrumentation = require('./ReactInstrumentation');
20
21
 
21
22
  var invariant = require('fbjs/lib/invariant');
@@ -71,38 +72,43 @@ var nextDebugID = 1;
71
72
  * Given a ReactNode, create an instance that will actually be mounted.
72
73
  *
73
74
  * @param {ReactNode} node
75
+ * @param {boolean} shouldHaveDebugID
74
76
  * @return {object} A new instance of the element's constructor.
75
77
  * @protected
76
78
  */
77
- function instantiateReactComponent(node) {
79
+ function instantiateReactComponent(node, shouldHaveDebugID) {
78
80
  var instance;
79
81
 
80
- var isEmpty = node === null || node === false;
81
- if (isEmpty) {
82
+ if (node === null || node === false) {
82
83
  instance = ReactEmptyComponent.create(instantiateReactComponent);
83
84
  } else if (typeof node === 'object') {
84
85
  var element = node;
85
- !(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;
86
87
 
87
88
  // Special case string values
88
89
  if (typeof element.type === 'string') {
89
- instance = ReactNativeComponent.createInternalComponent(element);
90
+ instance = ReactHostComponent.createInternalComponent(element);
90
91
  } else if (isInternalComponentType(element.type)) {
91
92
  // This is temporarily available for custom components that are not string
92
93
  // representations. I.e. ART. Once those are updated to use the string
93
94
  // representation, we can drop this code path.
94
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
+ }
95
101
  } else {
96
102
  instance = new ReactCompositeComponentWrapper(element);
97
103
  }
98
104
  } else if (typeof node === 'string' || typeof node === 'number') {
99
- instance = ReactNativeComponent.createInstanceForText(node);
105
+ instance = ReactHostComponent.createInstanceForText(node);
100
106
  } else {
101
- !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;
102
108
  }
103
109
 
104
110
  if (process.env.NODE_ENV !== 'production') {
105
- 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;
106
112
  }
107
113
 
108
114
  // These two fields are used by the DOM and ART diffing algorithms
@@ -112,21 +118,17 @@ function instantiateReactComponent(node) {
112
118
  instance._mountImage = null;
113
119
 
114
120
  if (process.env.NODE_ENV !== 'production') {
115
- instance._isOwnerNecessary = false;
116
- instance._warnedAboutRefsInRender = false;
117
- }
118
-
119
- if (process.env.NODE_ENV !== 'production') {
120
- var debugID = isEmpty ? 0 : nextDebugID++;
121
- instance._debugID = debugID;
122
-
123
- if (debugID !== 0) {
121
+ if (shouldHaveDebugID) {
122
+ var debugID = nextDebugID++;
123
+ instance._debugID = debugID;
124
124
  var displayName = getDisplayName(instance);
125
125
  ReactInstrumentation.debugTool.onSetDisplayName(debugID, displayName);
126
126
  var owner = node && node._owner;
127
127
  if (owner) {
128
128
  ReactInstrumentation.debugTool.onSetOwner(debugID, owner._debugID);
129
129
  }
130
+ } else {
131
+ instance._debugID = 0;
130
132
  }
131
133
  }
132
134
 
@@ -7,6 +7,7 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule isTextInputElement
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
@@ -35,7 +36,16 @@ var supportedInputTypes = {
35
36
 
36
37
  function isTextInputElement(elem) {
37
38
  var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
38
- return nodeName && (nodeName === 'input' && supportedInputTypes[elem.type] || nodeName === 'textarea');
39
+
40
+ if (nodeName === 'input') {
41
+ return !!supportedInputTypes[elem.type];
42
+ }
43
+
44
+ if (nodeName === 'textarea') {
45
+ return true;
46
+ }
47
+
48
+ return false;
39
49
  }
40
50
 
41
51
  module.exports = isTextInputElement;
package/lib/onlyChild.js CHANGED
@@ -10,6 +10,8 @@
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');
@@ -29,7 +31,7 @@ var invariant = require('fbjs/lib/invariant');
29
31
  * structure.
30
32
  */
31
33
  function onlyChild(children) {
32
- !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;
33
35
  return children;
34
36
  }
35
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,39 @@
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
+ */
12
+ 'use strict';
13
+
14
+ /**
15
+ * WARNING: DO NOT manually require this module.
16
+ * This is a replacement for `invariant(...)` used by the error code system
17
+ * and will _only_ be required by the corresponding babel pass.
18
+ * It always throws.
19
+ */
20
+
21
+ function reactProdInvariant(code) {
22
+ var argCount = arguments.length - 1;
23
+
24
+ var message = 'Minified React error #' + code + '; visit ' + 'http://facebook.github.io/react/docs/error-decoder.html?invariant=' + code;
25
+
26
+ for (var argIdx = 0; argIdx < argCount; argIdx++) {
27
+ message += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
28
+ }
29
+
30
+ message += ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.';
31
+
32
+ var error = new Error(message);
33
+ error.name = 'Invariant Violation';
34
+ error.framesToPop = 1; // we don't care about reactProdInvariant's own frame
35
+
36
+ throw error;
37
+ }
38
+
39
+ 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
 
@@ -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,9 +46,9 @@ 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
 
53
54
  /**
@@ -55,10 +56,10 @@ function invariantArrayCase(value, spec, command) {
55
56
  * See https://facebook.github.io/react/docs/update.html for details.
56
57
  */
57
58
  function update(value, spec) {
58
- !(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;
59
60
 
60
61
  if (hasOwnProperty.call(spec, COMMAND_SET)) {
61
- !(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;
62
63
 
63
64
  return spec[COMMAND_SET];
64
65
  }
@@ -67,8 +68,8 @@ function update(value, spec) {
67
68
 
68
69
  if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
69
70
  var mergeObj = spec[COMMAND_MERGE];
70
- !(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;
71
- !(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;
72
73
  _assign(nextValue, spec[COMMAND_MERGE]);
73
74
  }
74
75
 
@@ -87,16 +88,16 @@ function update(value, spec) {
87
88
  }
88
89
 
89
90
  if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
90
- !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;
91
- !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;
92
93
  spec[COMMAND_SPLICE].forEach(function (args) {
93
- !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;
94
95
  nextValue.splice.apply(nextValue, args);
95
96
  });
96
97
  }
97
98
 
98
99
  if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
99
- !(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;
100
101
  nextValue = spec[COMMAND_APPLY](nextValue);
101
102
  }
102
103