react 0.13.3 → 0.14.0-beta1

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 (189) hide show
  1. package/README.md +5 -2
  2. package/addons.js +7 -0
  3. package/dist/JSXTransformer.js +4101 -2432
  4. package/dist/react-with-addons.js +4389 -6277
  5. package/dist/react-with-addons.min.js +6 -8
  6. package/dist/react.js +4028 -5697
  7. package/dist/react.min.js +5 -6
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
  9. package/lib/BeforeInputEventPlugin.js +30 -118
  10. package/lib/CSSCore.js +12 -23
  11. package/lib/CSSProperty.js +4 -3
  12. package/lib/CSSPropertyOperations.js +14 -30
  13. package/lib/CallbackQueue.js +7 -10
  14. package/lib/ChangeEventPlugin.js +26 -88
  15. package/lib/ClientReactRootIndex.js +2 -2
  16. package/lib/DOMChildrenOperations.js +13 -33
  17. package/lib/DOMProperty.js +86 -147
  18. package/lib/DOMPropertyOperations.js +91 -67
  19. package/lib/Danger.js +19 -62
  20. package/lib/DefaultEventPluginOrder.js +2 -12
  21. package/lib/EnterLeaveEventPlugin.js +11 -33
  22. package/lib/EventConstants.js +2 -2
  23. package/lib/EventListener.js +11 -13
  24. package/lib/EventPluginHub.js +44 -47
  25. package/lib/EventPluginRegistry.js +18 -74
  26. package/lib/EventPluginUtils.js +33 -44
  27. package/lib/EventPropagators.js +23 -26
  28. package/lib/ExecutionEnvironment.js +4 -8
  29. package/lib/FallbackCompositionState.js +3 -3
  30. package/lib/HTMLDOMPropertyConfig.js +15 -20
  31. package/lib/LinkedStateMixin.js +3 -6
  32. package/lib/LinkedValueUtils.js +71 -89
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +20 -11
  35. package/lib/React.js +9 -129
  36. package/lib/ReactBrowserComponentMixin.js +9 -2
  37. package/lib/ReactBrowserEventEmitter.js +26 -82
  38. package/lib/ReactCSSTransitionGroup.js +13 -24
  39. package/lib/ReactCSSTransitionGroupChild.js +26 -28
  40. package/lib/ReactChildReconciler.js +11 -19
  41. package/lib/ReactChildren.js +24 -31
  42. package/lib/ReactClass.js +96 -267
  43. package/lib/ReactComponent.js +28 -57
  44. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  45. package/lib/ReactComponentEnvironment.js +6 -12
  46. package/lib/ReactComponentWithPureRenderMixin.js +6 -7
  47. package/lib/ReactCompositeComponent.js +115 -381
  48. package/lib/ReactCurrentOwner.js +1 -3
  49. package/lib/ReactDOM.js +4 -2
  50. package/lib/ReactDOMButton.js +16 -28
  51. package/lib/ReactDOMClient.js +90 -0
  52. package/lib/ReactDOMComponent.js +468 -156
  53. package/lib/ReactDOMIDOperations.js +25 -22
  54. package/lib/ReactDOMInput.js +79 -108
  55. package/lib/ReactDOMOption.js +58 -20
  56. package/lib/ReactDOMSelect.js +95 -83
  57. package/lib/ReactDOMSelection.js +5 -20
  58. package/lib/ReactDOMServer.js +24 -0
  59. package/lib/ReactDOMTextComponent.js +17 -18
  60. package/lib/ReactDOMTextarea.js +44 -69
  61. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  62. package/lib/ReactDefaultInjection.js +20 -76
  63. package/lib/ReactDefaultPerf.js +36 -69
  64. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  65. package/lib/ReactElement.js +26 -120
  66. package/lib/ReactElementValidator.js +56 -192
  67. package/lib/ReactEmptyComponent.js +7 -11
  68. package/lib/ReactErrorUtils.js +3 -3
  69. package/lib/ReactEventEmitterMixin.js +3 -13
  70. package/lib/ReactEventListener.js +58 -40
  71. package/lib/ReactFragment.js +33 -59
  72. package/lib/ReactInjection.js +1 -1
  73. package/lib/ReactInputSelection.js +14 -23
  74. package/lib/ReactInstanceHandles.js +29 -58
  75. package/lib/ReactInstanceMap.js +5 -5
  76. package/lib/ReactIsomorphic.js +70 -0
  77. package/lib/ReactLink.js +2 -4
  78. package/lib/ReactMarkupChecksum.js +5 -10
  79. package/lib/ReactMount.js +142 -285
  80. package/lib/ReactMultiChild.js +19 -45
  81. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  82. package/lib/ReactNativeComponent.js +6 -15
  83. package/lib/ReactNoopUpdateQueue.js +118 -0
  84. package/lib/ReactOwner.js +7 -24
  85. package/lib/ReactPerf.js +8 -12
  86. package/lib/ReactPropTransferer.js +4 -4
  87. package/lib/ReactPropTypeLocationNames.js +2 -2
  88. package/lib/ReactPropTypeLocations.js +1 -1
  89. package/lib/ReactPropTypes.js +41 -61
  90. package/lib/ReactReconcileTransaction.js +11 -36
  91. package/lib/ReactReconciler.js +14 -26
  92. package/lib/ReactRef.js +5 -8
  93. package/lib/ReactRootIndex.js +2 -2
  94. package/lib/ReactServerBatchingStrategy.js +23 -0
  95. package/lib/ReactServerRendering.js +20 -15
  96. package/lib/ReactServerRenderingTransaction.js +9 -34
  97. package/lib/ReactStateSetters.js +6 -6
  98. package/lib/ReactTestUtils.js +137 -190
  99. package/lib/ReactTransitionChildMapping.js +5 -7
  100. package/lib/ReactTransitionEvents.js +5 -5
  101. package/lib/ReactTransitionGroup.js +30 -52
  102. package/lib/ReactUpdateQueue.js +69 -107
  103. package/lib/ReactUpdates.js +26 -81
  104. package/lib/ReactWithAddons.js +5 -6
  105. package/lib/SVGDOMPropertyConfig.js +39 -4
  106. package/lib/SelectEventPlugin.js +31 -33
  107. package/lib/ServerReactRootIndex.js +2 -2
  108. package/lib/SimpleEventPlugin.js +138 -130
  109. package/lib/SyntheticClipboardEvent.js +5 -9
  110. package/lib/SyntheticCompositionEvent.js +4 -10
  111. package/lib/SyntheticDragEvent.js +3 -3
  112. package/lib/SyntheticEvent.js +14 -15
  113. package/lib/SyntheticFocusEvent.js +3 -3
  114. package/lib/SyntheticInputEvent.js +4 -10
  115. package/lib/SyntheticKeyboardEvent.js +6 -6
  116. package/lib/SyntheticMouseEvent.js +10 -16
  117. package/lib/SyntheticTouchEvent.js +3 -3
  118. package/lib/SyntheticUIEvent.js +5 -5
  119. package/lib/SyntheticWheelEvent.js +13 -17
  120. package/lib/Transaction.js +22 -28
  121. package/lib/ViewportMetrics.js +2 -2
  122. package/lib/accumulateInto.js +2 -5
  123. package/lib/adler32.js +2 -4
  124. package/lib/camelize.js +4 -2
  125. package/lib/camelizeStyleName.js +2 -2
  126. package/lib/cloneWithProps.js +6 -12
  127. package/lib/containsNode.js +29 -16
  128. package/lib/createArrayFromMixed.js +17 -16
  129. package/lib/createNodesFromMarkup.js +6 -8
  130. package/lib/dangerousStyleValue.js +2 -3
  131. package/lib/deprecated.js +47 -0
  132. package/lib/emptyFunction.js +10 -4
  133. package/lib/emptyObject.js +1 -1
  134. package/lib/escapeTextContentForBrowser.js +1 -1
  135. package/lib/findDOMNode.js +7 -27
  136. package/lib/flattenChildren.js +4 -10
  137. package/lib/focusNode.js +2 -3
  138. package/lib/forEachAccumulated.js +3 -3
  139. package/lib/getActiveElement.js +4 -2
  140. package/lib/getEventCharCode.js +2 -2
  141. package/lib/getEventKey.js +1 -1
  142. package/lib/getEventModifierState.js +1 -2
  143. package/lib/getEventTarget.js +1 -1
  144. package/lib/getIteratorFn.js +2 -4
  145. package/lib/getMarkupWrap.js +18 -40
  146. package/lib/getNodeForCharacterOffset.js +1 -1
  147. package/lib/getTextContentAccessor.js +2 -4
  148. package/lib/getUnboundedScrollPosition.js +1 -1
  149. package/lib/hyphenate.js +3 -1
  150. package/lib/hyphenateStyleName.js +2 -2
  151. package/lib/instantiateReactComponent.js +23 -43
  152. package/lib/invariant.js +8 -12
  153. package/lib/isEventSupported.js +7 -10
  154. package/lib/isNode.js +4 -6
  155. package/lib/isTextInputElement.js +3 -4
  156. package/lib/isTextNode.js +3 -1
  157. package/lib/joinClasses.js +3 -3
  158. package/lib/keyMirror.js +3 -6
  159. package/lib/keyOf.js +4 -3
  160. package/lib/mapObject.js +1 -1
  161. package/lib/memoizeStringOnly.js +2 -2
  162. package/lib/onlyChild.js +2 -5
  163. package/lib/performance.js +2 -5
  164. package/lib/performanceNow.js +3 -1
  165. package/lib/quoteAttributeValueForBrowser.js +1 -1
  166. package/lib/renderSubtreeIntoContainer.js +16 -0
  167. package/lib/setInnerHTML.js +11 -8
  168. package/lib/setTextContent.js +3 -3
  169. package/lib/shallowCompare.js +24 -0
  170. package/lib/shallowEqual.js +17 -11
  171. package/lib/shouldUpdateReactComponent.js +3 -64
  172. package/lib/toArray.js +8 -19
  173. package/lib/traverseAllChildren.js +23 -90
  174. package/lib/update.js +25 -85
  175. package/lib/validateDOMNesting.js +363 -0
  176. package/lib/warning.js +15 -17
  177. package/package.json +3 -3
  178. package/react.js +53 -1
  179. package/lib/LocalEventTrapMixin.js +0 -53
  180. package/lib/MobileSafariClickEventPlugin.js +0 -56
  181. package/lib/ReactContext.js +0 -74
  182. package/lib/ReactDOMForm.js +0 -47
  183. package/lib/ReactDOMIframe.js +0 -43
  184. package/lib/ReactDOMImg.js +0 -44
  185. package/lib/ReactLifeCycle.js +0 -35
  186. package/lib/ReactPutListenerQueue.js +0 -54
  187. package/lib/createFullPageComponent.js +0 -58
  188. package/lib/cx.js +0 -52
  189. package/lib/getReactRootElementInContainer.js +0 -33
@@ -22,15 +22,9 @@ var warning = require("./warning");
22
22
  function flattenSingleChildIntoContext(traverseContext, child, name) {
23
23
  // We found a component instance.
24
24
  var result = traverseContext;
25
- var keyUnique = !result.hasOwnProperty(name);
26
- if ("production" !== process.env.NODE_ENV) {
27
- ("production" !== process.env.NODE_ENV ? warning(
28
- keyUnique,
29
- 'flattenChildren(...): Encountered two children with the same key, ' +
30
- '`%s`. Child keys must be unique; when two children share a key, only ' +
31
- 'the first child will be used.',
32
- name
33
- ) : null);
25
+ var keyUnique = result[name] === undefined;
26
+ if ('production' !== process.env.NODE_ENV) {
27
+ 'production' !== process.env.NODE_ENV ? 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.', name) : undefined;
34
28
  }
35
29
  if (keyUnique && child != null) {
36
30
  result[name] = child;
@@ -51,4 +45,4 @@ function flattenChildren(children) {
51
45
  return result;
52
46
  }
53
47
 
54
- module.exports = flattenChildren;
48
+ module.exports = flattenChildren;
package/lib/focusNode.js CHANGED
@@ -20,8 +20,7 @@ function focusNode(node) {
20
20
  // reasons that are too expensive and fragile to test.
21
21
  try {
22
22
  node.focus();
23
- } catch(e) {
24
- }
23
+ } catch (e) {}
25
24
  }
26
25
 
27
- module.exports = focusNode;
26
+ module.exports = focusNode;
@@ -12,13 +12,13 @@
12
12
  'use strict';
13
13
 
14
14
  /**
15
- * @param {array} an "accumulation" of items which is either an Array or
15
+ * @param {array} arr an "accumulation" of items which is either an Array or
16
16
  * a single item. Useful when paired with the `accumulate` module. This is a
17
17
  * simple utility that allows us to reason about a collection of items, but
18
18
  * handling the case when there is exactly one item (and we do not need to
19
19
  * allocate an array).
20
20
  */
21
- var forEachAccumulated = function(arr, cb, scope) {
21
+ var forEachAccumulated = function (arr, cb, scope) {
22
22
  if (Array.isArray(arr)) {
23
23
  arr.forEach(cb, scope);
24
24
  } else if (arr) {
@@ -26,4 +26,4 @@ var forEachAccumulated = function(arr, cb, scope) {
26
26
  }
27
27
  };
28
28
 
29
- module.exports = forEachAccumulated;
29
+ module.exports = forEachAccumulated;
@@ -16,7 +16,9 @@
16
16
  *
17
17
  * The activeElement will be null only if the document body is not yet defined.
18
18
  */
19
- function getActiveElement() /*?DOMElement*/ {
19
+ "use strict";
20
+
21
+ function getActiveElement() /*?DOMElement*/{
20
22
  try {
21
23
  return document.activeElement || document.body;
22
24
  } catch (e) {
@@ -24,4 +26,4 @@ function getActiveElement() /*?DOMElement*/ {
24
26
  }
25
27
  }
26
28
 
27
- module.exports = getActiveElement;
29
+ module.exports = getActiveElement;
@@ -20,7 +20,7 @@
20
20
  * presumably because it does not produce a tab-character in browsers.
21
21
  *
22
22
  * @param {object} nativeEvent Native browser event.
23
- * @return {string} Normalized `charCode` property.
23
+ * @return {number} Normalized `charCode` property.
24
24
  */
25
25
  function getEventCharCode(nativeEvent) {
26
26
  var charCode;
@@ -47,4 +47,4 @@ function getEventCharCode(nativeEvent) {
47
47
  return 0;
48
48
  }
49
49
 
50
- module.exports = getEventCharCode;
50
+ module.exports = getEventCharCode;
@@ -100,4 +100,4 @@ function getEventKey(nativeEvent) {
100
100
  return '';
101
101
  }
102
102
 
103
- module.exports = getEventKey;
103
+ module.exports = getEventKey;
@@ -28,7 +28,6 @@ var modifierKeyToProp = {
28
28
  // modifier keys exposed by the event itself, does not support Lock-keys.
29
29
  // Currently, all major browsers except Chrome seems to support Lock-keys.
30
30
  function modifierStateGetter(keyArg) {
31
- /*jshint validthis:true */
32
31
  var syntheticEvent = this;
33
32
  var nativeEvent = syntheticEvent.nativeEvent;
34
33
  if (nativeEvent.getModifierState) {
@@ -42,4 +41,4 @@ function getEventModifierState(nativeEvent) {
42
41
  return modifierStateGetter;
43
42
  }
44
43
 
45
- module.exports = getEventModifierState;
44
+ module.exports = getEventModifierState;
@@ -26,4 +26,4 @@ function getEventTarget(nativeEvent) {
26
26
  return target.nodeType === 3 ? target.parentNode : target;
27
27
  }
28
28
 
29
- module.exports = getEventTarget;
29
+ module.exports = getEventTarget;
@@ -31,12 +31,10 @@ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
31
31
  * @return {?function}
32
32
  */
33
33
  function getIteratorFn(maybeIterable) {
34
- var iteratorFn = maybeIterable && (
35
- (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL])
36
- );
34
+ var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
37
35
  if (typeof iteratorFn === 'function') {
38
36
  return iteratorFn;
39
37
  }
40
38
  }
41
39
 
42
- module.exports = getIteratorFn;
40
+ module.exports = getIteratorFn;
@@ -9,6 +9,8 @@
9
9
  * @providesModule getMarkupWrap
10
10
  */
11
11
 
12
+ 'use strict';
13
+
12
14
  var ExecutionEnvironment = require("./ExecutionEnvironment");
13
15
 
14
16
  var invariant = require("./invariant");
@@ -16,8 +18,7 @@ var invariant = require("./invariant");
16
18
  /**
17
19
  * Dummy container used to detect which wraps are necessary.
18
20
  */
19
- var dummyNode =
20
- ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
21
+ var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
21
22
 
22
23
  /**
23
24
  * Some browsers cannot use `innerHTML` to render certain elements standalone,
@@ -25,30 +26,14 @@ var dummyNode =
25
26
  *
26
27
  * In IE8, certain elements cannot render alone, so wrap all elements ('*').
27
28
  */
28
- var shouldWrap = {
29
- // Force wrapping for SVG elements because if they get created inside a <div>,
30
- // they will be initialized in the wrong namespace (and will not display).
31
- 'circle': true,
32
- 'clipPath': true,
33
- 'defs': true,
34
- 'ellipse': true,
35
- 'g': true,
36
- 'line': true,
37
- 'linearGradient': true,
38
- 'path': true,
39
- 'polygon': true,
40
- 'polyline': true,
41
- 'radialGradient': true,
42
- 'rect': true,
43
- 'stop': true,
44
- 'text': true
45
- };
29
+
30
+ var shouldWrap = {};
46
31
 
47
32
  var selectWrap = [1, '<select multiple="true">', '</select>'];
48
33
  var tableWrap = [1, '<table>', '</table>'];
49
34
  var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
50
35
 
51
- var svgWrap = [1, '<svg>', '</svg>'];
36
+ var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>'];
52
37
 
53
38
  var markupWrap = {
54
39
  '*': [1, '?<div>', '</div>'],
@@ -69,24 +54,18 @@ var markupWrap = {
69
54
  'thead': tableWrap,
70
55
 
71
56
  'td': trWrap,
72
- 'th': trWrap,
73
-
74
- 'circle': svgWrap,
75
- 'clipPath': svgWrap,
76
- 'defs': svgWrap,
77
- 'ellipse': svgWrap,
78
- 'g': svgWrap,
79
- 'line': svgWrap,
80
- 'linearGradient': svgWrap,
81
- 'path': svgWrap,
82
- 'polygon': svgWrap,
83
- 'polyline': svgWrap,
84
- 'radialGradient': svgWrap,
85
- 'rect': svgWrap,
86
- 'stop': svgWrap,
87
- 'text': svgWrap
57
+ 'th': trWrap
88
58
  };
89
59
 
60
+ // Initilize the SVG elements since we know they'll always need to be wrapped
61
+ // consistently. If they are created inside a <div> they will be initialized in
62
+ // the wrong namespace (and will not display).
63
+ var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan'];
64
+ svgElements.forEach(function (nodeName) {
65
+ markupWrap[nodeName] = svgWrap;
66
+ shouldWrap[nodeName] = true;
67
+ });
68
+
90
69
  /**
91
70
  * Gets the markup wrap configuration for the supplied `nodeName`.
92
71
  *
@@ -96,7 +75,7 @@ var markupWrap = {
96
75
  * @return {?array} Markup wrap configuration, if applicable.
97
76
  */
98
77
  function getMarkupWrap(nodeName) {
99
- ("production" !== process.env.NODE_ENV ? invariant(!!dummyNode, 'Markup wrapping node not initialized') : invariant(!!dummyNode));
78
+ !!!dummyNode ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : undefined;
100
79
  if (!markupWrap.hasOwnProperty(nodeName)) {
101
80
  nodeName = '*';
102
81
  }
@@ -111,5 +90,4 @@ function getMarkupWrap(nodeName) {
111
90
  return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
112
91
  }
113
92
 
114
-
115
- module.exports = getMarkupWrap;
93
+ module.exports = getMarkupWrap;
@@ -70,4 +70,4 @@ function getNodeForCharacterOffset(root, offset) {
70
70
  }
71
71
  }
72
72
 
73
- module.exports = getNodeForCharacterOffset;
73
+ module.exports = getNodeForCharacterOffset;
@@ -25,11 +25,9 @@ function getTextContentAccessor() {
25
25
  if (!contentKey && ExecutionEnvironment.canUseDOM) {
26
26
  // Prefer textContent to innerText because many browsers support both but
27
27
  // SVG <text> elements don't support innerText even when <div> does.
28
- contentKey = 'textContent' in document.documentElement ?
29
- 'textContent' :
30
- 'innerText';
28
+ contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText';
31
29
  }
32
30
  return contentKey;
33
31
  }
34
32
 
35
- module.exports = getTextContentAccessor;
33
+ module.exports = getTextContentAccessor;
@@ -35,4 +35,4 @@ function getUnboundedScrollPosition(scrollable) {
35
35
  };
36
36
  }
37
37
 
38
- module.exports = getUnboundedScrollPosition;
38
+ module.exports = getUnboundedScrollPosition;
package/lib/hyphenate.js CHANGED
@@ -10,6 +10,8 @@
10
10
  * @typechecks
11
11
  */
12
12
 
13
+ 'use strict';
14
+
13
15
  var _uppercasePattern = /([A-Z])/g;
14
16
 
15
17
  /**
@@ -28,4 +30,4 @@ function hyphenate(string) {
28
30
  return string.replace(_uppercasePattern, '-$1').toLowerCase();
29
31
  }
30
32
 
31
- module.exports = hyphenate;
33
+ module.exports = hyphenate;
@@ -10,7 +10,7 @@
10
10
  * @typechecks
11
11
  */
12
12
 
13
- "use strict";
13
+ 'use strict';
14
14
 
15
15
  var hyphenate = require("./hyphenate");
16
16
 
@@ -36,4 +36,4 @@ function hyphenateStyleName(string) {
36
36
  return hyphenate(string).replace(msPattern, '-ms-');
37
37
  }
38
38
 
39
- module.exports = hyphenateStyleName;
39
+ module.exports = hyphenateStyleName;
@@ -21,14 +21,20 @@ var invariant = require("./invariant");
21
21
  var warning = require("./warning");
22
22
 
23
23
  // To avoid a cyclic dependency, we create the final class in this module
24
- var ReactCompositeComponentWrapper = function() { };
25
- assign(
26
- ReactCompositeComponentWrapper.prototype,
27
- ReactCompositeComponent.Mixin,
28
- {
29
- _instantiateReactComponent: instantiateReactComponent
24
+ var ReactCompositeComponentWrapper = function () {};
25
+ assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
26
+ _instantiateReactComponent: instantiateReactComponent
27
+ });
28
+
29
+ function getDeclarationErrorAddendum(owner) {
30
+ if (owner) {
31
+ var name = owner.getName();
32
+ if (name) {
33
+ return ' Check the render method of `' + name + '`.';
34
+ }
30
35
  }
31
- );
36
+ return '';
37
+ }
32
38
 
33
39
  /**
34
40
  * Check if the type reference is a known internal type. I.e. not a user
@@ -38,23 +44,17 @@ assign(
38
44
  * @return {boolean} Returns true if this is a valid internal type.
39
45
  */
40
46
  function isInternalComponentType(type) {
41
- return (
42
- typeof type === 'function' &&
43
- typeof type.prototype !== 'undefined' &&
44
- typeof type.prototype.mountComponent === 'function' &&
45
- typeof type.prototype.receiveComponent === 'function'
46
- );
47
+ return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
47
48
  }
48
49
 
49
50
  /**
50
51
  * Given a ReactNode, create an instance that will actually be mounted.
51
52
  *
52
53
  * @param {ReactNode} node
53
- * @param {*} parentCompositeType The composite type that resolved this.
54
54
  * @return {object} A new instance of the element's constructor.
55
55
  * @protected
56
56
  */
57
- function instantiateReactComponent(node, parentCompositeType) {
57
+ function instantiateReactComponent(node) {
58
58
  var instance;
59
59
 
60
60
  if (node === null || node === false) {
@@ -63,21 +63,11 @@ function instantiateReactComponent(node, parentCompositeType) {
63
63
 
64
64
  if (typeof node === 'object') {
65
65
  var element = node;
66
- if ("production" !== process.env.NODE_ENV) {
67
- ("production" !== process.env.NODE_ENV ? warning(
68
- element && (typeof element.type === 'function' ||
69
- typeof element.type === 'string'),
70
- 'Only functions or strings can be mounted as React components.'
71
- ) : null);
72
- }
66
+ !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? 'production' !== process.env.NODE_ENV ? 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) : undefined;
73
67
 
74
68
  // Special case string values
75
- if (parentCompositeType === element.type &&
76
- typeof element.type === 'string') {
77
- // Avoid recursion if the wrapper renders itself.
69
+ if (typeof element.type === 'string') {
78
70
  instance = ReactNativeComponent.createInternalComponent(element);
79
- // All native components are currently wrapped in a composite so we're
80
- // safe to assume that this is what we should instantiate.
81
71
  } else if (isInternalComponentType(element.type)) {
82
72
  // This is temporarily available for custom components that are not string
83
73
  // represenations. I.e. ART. Once those are updated to use the string
@@ -89,21 +79,11 @@ function instantiateReactComponent(node, parentCompositeType) {
89
79
  } else if (typeof node === 'string' || typeof node === 'number') {
90
80
  instance = ReactNativeComponent.createInstanceForText(node);
91
81
  } else {
92
- ("production" !== process.env.NODE_ENV ? invariant(
93
- false,
94
- 'Encountered invalid React node of type %s',
95
- typeof node
96
- ) : invariant(false));
82
+ !false ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : undefined;
97
83
  }
98
84
 
99
- if ("production" !== process.env.NODE_ENV) {
100
- ("production" !== process.env.NODE_ENV ? warning(
101
- typeof instance.construct === 'function' &&
102
- typeof instance.mountComponent === 'function' &&
103
- typeof instance.receiveComponent === 'function' &&
104
- typeof instance.unmountComponent === 'function',
105
- 'Only React Components can be mounted.'
106
- ) : null);
85
+ if ('production' !== process.env.NODE_ENV) {
86
+ 'production' !== process.env.NODE_ENV ? warning(typeof instance.construct === 'function' && typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : undefined;
107
87
  }
108
88
 
109
89
  // Sets up the instance. This can probably just move into the constructor now.
@@ -115,14 +95,14 @@ function instantiateReactComponent(node, parentCompositeType) {
115
95
  instance._mountIndex = 0;
116
96
  instance._mountImage = null;
117
97
 
118
- if ("production" !== process.env.NODE_ENV) {
98
+ if ('production' !== process.env.NODE_ENV) {
119
99
  instance._isOwnerNecessary = false;
120
100
  instance._warnedAboutRefsInRender = false;
121
101
  }
122
102
 
123
103
  // Internal instances should fully constructed at this point, so they should
124
104
  // not get any new fields added to them at this point.
125
- if ("production" !== process.env.NODE_ENV) {
105
+ if ('production' !== process.env.NODE_ENV) {
126
106
  if (Object.preventExtensions) {
127
107
  Object.preventExtensions(instance);
128
108
  }
@@ -131,4 +111,4 @@ function instantiateReactComponent(node, parentCompositeType) {
131
111
  return instance;
132
112
  }
133
113
 
134
- module.exports = instantiateReactComponent;
114
+ module.exports = instantiateReactComponent;
package/lib/invariant.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * @providesModule invariant
10
10
  */
11
11
 
12
- "use strict";
12
+ 'use strict';
13
13
 
14
14
  /**
15
15
  * Use invariant() to assert state which your program assumes to be true.
@@ -22,8 +22,8 @@
22
22
  * will remain to ensure logic does not differ in production.
23
23
  */
24
24
 
25
- var invariant = function(condition, format, a, b, c, d, e, f) {
26
- if ("production" !== process.env.NODE_ENV) {
25
+ var invariant = function (condition, format, a, b, c, d, e, f) {
26
+ if ('production' !== process.env.NODE_ENV) {
27
27
  if (format === undefined) {
28
28
  throw new Error('invariant requires an error message argument');
29
29
  }
@@ -32,17 +32,13 @@ var invariant = function(condition, format, a, b, c, d, e, f) {
32
32
  if (!condition) {
33
33
  var error;
34
34
  if (format === undefined) {
35
- error = new Error(
36
- 'Minified exception occurred; use the non-minified dev environment ' +
37
- 'for the full error message and additional helpful warnings.'
38
- );
35
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
39
36
  } else {
40
37
  var args = [a, b, c, d, e, f];
41
38
  var argIndex = 0;
42
- error = new Error(
43
- 'Invariant Violation: ' +
44
- format.replace(/%s/g, function() { return args[argIndex++]; })
45
- );
39
+ error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () {
40
+ return args[argIndex++];
41
+ }));
46
42
  }
47
43
 
48
44
  error.framesToPop = 1; // we don't care about invariant's own frame
@@ -50,4 +46,4 @@ var invariant = function(condition, format, a, b, c, d, e, f) {
50
46
  }
51
47
  };
52
48
 
53
- module.exports = invariant;
49
+ module.exports = invariant;