react 0.13.2 → 0.14.0-alpha3

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 (197) hide show
  1. package/README.md +1 -1
  2. package/addons.js +7 -0
  3. package/addons/CSSTransitionGroup.js +1 -0
  4. package/addons/LinkedStateMixin.js +1 -0
  5. package/addons/Perf.js +1 -0
  6. package/addons/PureRenderMixin.js +1 -0
  7. package/addons/TestUtils.js +1 -0
  8. package/addons/TransitionGroup.js +1 -0
  9. package/addons/batchedUpdates.js +1 -0
  10. package/addons/cloneWithProps.js +1 -0
  11. package/addons/createFragment.js +1 -0
  12. package/addons/renderSubtreeIntoContainer.js +1 -0
  13. package/addons/shallowCompare.js +1 -0
  14. package/addons/update.js +1 -0
  15. package/dist/JSXTransformer.js +3355 -1685
  16. package/dist/react-with-addons.js +3320 -5133
  17. package/dist/react-with-addons.min.js +6 -7
  18. package/dist/react.js +2962 -4548
  19. package/dist/react.min.js +5 -5
  20. package/lib/AutoFocusMixin.js +4 -3
  21. package/lib/BeforeInputEventPlugin.js +30 -118
  22. package/lib/CSSCore.js +12 -23
  23. package/lib/CSSProperty.js +4 -3
  24. package/lib/CSSPropertyOperations.js +14 -30
  25. package/lib/CallbackQueue.js +7 -10
  26. package/lib/ChangeEventPlugin.js +24 -88
  27. package/lib/ClientReactRootIndex.js +2 -2
  28. package/lib/DOMChildrenOperations.js +13 -33
  29. package/lib/DOMProperty.js +41 -67
  30. package/lib/DOMPropertyOperations.js +30 -51
  31. package/lib/Danger.js +19 -62
  32. package/lib/DefaultEventPluginOrder.js +2 -12
  33. package/lib/EnterLeaveEventPlugin.js +11 -33
  34. package/lib/EventConstants.js +2 -2
  35. package/lib/EventListener.js +11 -13
  36. package/lib/EventPluginHub.js +44 -47
  37. package/lib/EventPluginRegistry.js +18 -74
  38. package/lib/EventPluginUtils.js +27 -38
  39. package/lib/EventPropagators.js +23 -26
  40. package/lib/ExecutionEnvironment.js +4 -8
  41. package/lib/FallbackCompositionState.js +3 -3
  42. package/lib/HTMLDOMPropertyConfig.js +7 -19
  43. package/lib/LinkedStateMixin.js +3 -6
  44. package/lib/LinkedValueUtils.js +34 -64
  45. package/lib/LocalEventTrapMixin.js +9 -16
  46. package/lib/Object.assign.js +1 -1
  47. package/lib/PooledClass.js +8 -11
  48. package/lib/React.js +9 -129
  49. package/lib/ReactBrowserComponentMixin.js +9 -2
  50. package/lib/ReactBrowserEventEmitter.js +26 -82
  51. package/lib/ReactCSSTransitionGroup.js +13 -24
  52. package/lib/ReactCSSTransitionGroupChild.js +18 -28
  53. package/lib/ReactChildReconciler.js +11 -19
  54. package/lib/ReactChildren.js +21 -28
  55. package/lib/ReactClass.js +81 -234
  56. package/lib/ReactComponent.js +17 -33
  57. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  58. package/lib/ReactComponentEnvironment.js +6 -12
  59. package/lib/ReactComponentWithPureRenderMixin.js +4 -5
  60. package/lib/ReactCompositeComponent.js +87 -311
  61. package/lib/ReactContext.js +2 -44
  62. package/lib/ReactCurrentOwner.js +1 -3
  63. package/lib/ReactDOM.js +4 -2
  64. package/lib/ReactDOMButton.js +3 -4
  65. package/lib/ReactDOMClient.js +85 -0
  66. package/lib/ReactDOMComponent.js +182 -146
  67. package/lib/ReactDOMForm.js +3 -3
  68. package/lib/ReactDOMIDOperations.js +11 -22
  69. package/lib/ReactDOMIframe.js +3 -3
  70. package/lib/ReactDOMImg.js +3 -3
  71. package/lib/ReactDOMInput.js +22 -35
  72. package/lib/ReactDOMOption.js +67 -10
  73. package/lib/ReactDOMSelect.js +50 -28
  74. package/lib/ReactDOMSelection.js +5 -20
  75. package/lib/ReactDOMServer.js +24 -0
  76. package/lib/ReactDOMTextComponent.js +17 -18
  77. package/lib/ReactDOMTextarea.js +15 -27
  78. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  79. package/lib/ReactDefaultInjection.js +31 -40
  80. package/lib/ReactDefaultPerf.js +36 -69
  81. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  82. package/lib/ReactElement.js +24 -57
  83. package/lib/ReactElementValidator.js +38 -105
  84. package/lib/ReactEmptyComponent.js +7 -11
  85. package/lib/ReactErrorUtils.js +2 -2
  86. package/lib/ReactEventEmitterMixin.js +3 -12
  87. package/lib/ReactEventListener.js +16 -38
  88. package/lib/ReactFragment.js +23 -54
  89. package/lib/ReactInjection.js +1 -1
  90. package/lib/ReactInputSelection.js +11 -21
  91. package/lib/ReactInstanceHandles.js +27 -57
  92. package/lib/ReactInstanceMap.js +5 -5
  93. package/lib/ReactIsomorphic.js +70 -0
  94. package/lib/ReactLifeCycle.js +1 -1
  95. package/lib/ReactLink.js +2 -4
  96. package/lib/ReactMarkupChecksum.js +5 -10
  97. package/lib/ReactMount.js +137 -260
  98. package/lib/ReactMultiChild.js +19 -45
  99. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  100. package/lib/ReactNativeComponent.js +7 -11
  101. package/lib/ReactOwner.js +7 -24
  102. package/lib/ReactPerf.js +8 -12
  103. package/lib/ReactPropTransferer.js +4 -4
  104. package/lib/ReactPropTypeLocationNames.js +2 -2
  105. package/lib/ReactPropTypeLocations.js +1 -1
  106. package/lib/ReactPropTypes.js +41 -61
  107. package/lib/ReactReconcileTransaction.js +9 -34
  108. package/lib/ReactReconciler.js +9 -19
  109. package/lib/ReactRef.js +5 -8
  110. package/lib/ReactRootIndex.js +2 -2
  111. package/lib/ReactServerRendering.js +7 -15
  112. package/lib/ReactServerRenderingTransaction.js +7 -32
  113. package/lib/ReactStateSetters.js +6 -6
  114. package/lib/ReactTestUtils.js +93 -165
  115. package/lib/ReactTransitionChildMapping.js +5 -7
  116. package/lib/ReactTransitionEvents.js +5 -5
  117. package/lib/ReactTransitionGroup.js +30 -52
  118. package/lib/ReactUpdateQueue.js +27 -90
  119. package/lib/ReactUpdates.js +27 -79
  120. package/lib/ReactWithAddons.js +7 -6
  121. package/lib/SVGDOMPropertyConfig.js +41 -4
  122. package/lib/SelectEventPlugin.js +28 -29
  123. package/lib/ServerReactRootIndex.js +2 -2
  124. package/lib/SimpleEventPlugin.js +136 -128
  125. package/lib/SyntheticClipboardEvent.js +3 -7
  126. package/lib/SyntheticCompositionEvent.js +3 -9
  127. package/lib/SyntheticDragEvent.js +1 -1
  128. package/lib/SyntheticEvent.js +8 -10
  129. package/lib/SyntheticFocusEvent.js +1 -1
  130. package/lib/SyntheticInputEvent.js +3 -9
  131. package/lib/SyntheticKeyboardEvent.js +4 -4
  132. package/lib/SyntheticMouseEvent.js +8 -14
  133. package/lib/SyntheticTouchEvent.js +1 -1
  134. package/lib/SyntheticUIEvent.js +3 -3
  135. package/lib/SyntheticWheelEvent.js +11 -15
  136. package/lib/Transaction.js +12 -24
  137. package/lib/ViewportMetrics.js +2 -2
  138. package/lib/accumulateInto.js +2 -5
  139. package/lib/adler32.js +2 -4
  140. package/lib/camelize.js +4 -2
  141. package/lib/camelizeStyleName.js +2 -2
  142. package/lib/cloneWithProps.js +5 -11
  143. package/lib/containsNode.js +29 -16
  144. package/lib/createArrayFromMixed.js +17 -16
  145. package/lib/createFullPageComponent.js +4 -11
  146. package/lib/createNodesFromMarkup.js +6 -8
  147. package/lib/dangerousStyleValue.js +2 -3
  148. package/lib/emptyFunction.js +10 -4
  149. package/lib/emptyObject.js +1 -1
  150. package/lib/escapeTextContentForBrowser.js +1 -1
  151. package/lib/findDOMNode.js +5 -24
  152. package/lib/flattenChildren.js +4 -10
  153. package/lib/focusNode.js +2 -3
  154. package/lib/forEachAccumulated.js +2 -2
  155. package/lib/getActiveElement.js +4 -2
  156. package/lib/getEventCharCode.js +1 -1
  157. package/lib/getEventKey.js +1 -1
  158. package/lib/getEventModifierState.js +1 -1
  159. package/lib/getEventTarget.js +1 -1
  160. package/lib/getIteratorFn.js +2 -4
  161. package/lib/getMarkupWrap.js +7 -5
  162. package/lib/getNodeForCharacterOffset.js +1 -1
  163. package/lib/getTextContentAccessor.js +2 -4
  164. package/lib/getUnboundedScrollPosition.js +1 -1
  165. package/lib/hyphenate.js +3 -1
  166. package/lib/hyphenateStyleName.js +2 -2
  167. package/lib/instantiateReactComponent.js +14 -38
  168. package/lib/invariant.js +8 -12
  169. package/lib/isEventSupported.js +7 -10
  170. package/lib/isNode.js +4 -6
  171. package/lib/isTextInputElement.js +2 -4
  172. package/lib/isTextNode.js +3 -1
  173. package/lib/joinClasses.js +2 -2
  174. package/lib/keyMirror.js +3 -6
  175. package/lib/keyOf.js +4 -3
  176. package/lib/mapObject.js +1 -1
  177. package/lib/memoizeStringOnly.js +2 -2
  178. package/lib/onlyChild.js +2 -5
  179. package/lib/performance.js +2 -5
  180. package/lib/performanceNow.js +3 -1
  181. package/lib/quoteAttributeValueForBrowser.js +1 -1
  182. package/lib/renderSubtreeIntoContainer.js +16 -0
  183. package/lib/setInnerHTML.js +11 -8
  184. package/lib/setTextContent.js +3 -3
  185. package/lib/shallowCompare.js +24 -0
  186. package/lib/shallowEqual.js +17 -11
  187. package/lib/shouldUpdateReactComponent.js +3 -64
  188. package/lib/toArray.js +8 -19
  189. package/lib/traverseAllChildren.js +22 -89
  190. package/lib/update.js +25 -85
  191. package/lib/validateDOMNesting.js +363 -0
  192. package/lib/warning.js +17 -15
  193. package/package.json +3 -3
  194. package/lib/MobileSafariClickEventPlugin.js +0 -56
  195. package/lib/ReactPutListenerQueue.js +0 -54
  196. package/lib/cx.js +0 -52
  197. package/lib/getReactRootElementInContainer.js +0 -33
@@ -9,6 +9,8 @@
9
9
  * @providesModule ReactDefaultPerfAnalysis
10
10
  */
11
11
 
12
+ 'use strict';
13
+
12
14
  var assign = require("./Object.assign");
13
15
 
14
16
  // Don't try to save users less than 1.2ms (a number I made up)
@@ -46,7 +48,7 @@ function getDOMSummary(measurements) {
46
48
  var id;
47
49
 
48
50
  for (id in measurement.writes) {
49
- measurement.writes[id].forEach(function(write) {
51
+ measurement.writes[id].forEach(function (write) {
50
52
  items.push({
51
53
  id: id,
52
54
  type: DOM_OPERATION_TYPES[write.type] || write.type,
@@ -64,11 +66,7 @@ function getExclusiveSummary(measurements) {
64
66
 
65
67
  for (var i = 0; i < measurements.length; i++) {
66
68
  var measurement = measurements[i];
67
- var allIDs = assign(
68
- {},
69
- measurement.exclusive,
70
- measurement.inclusive
71
- );
69
+ var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
72
70
 
73
71
  for (var id in allIDs) {
74
72
  displayName = measurement.displayNames[id].current;
@@ -103,7 +101,7 @@ function getExclusiveSummary(measurements) {
103
101
  }
104
102
  }
105
103
 
106
- arr.sort(function(a, b) {
104
+ arr.sort(function (a, b) {
107
105
  return b.exclusive - a.exclusive;
108
106
  });
109
107
 
@@ -116,11 +114,7 @@ function getInclusiveSummary(measurements, onlyClean) {
116
114
 
117
115
  for (var i = 0; i < measurements.length; i++) {
118
116
  var measurement = measurements[i];
119
- var allIDs = assign(
120
- {},
121
- measurement.exclusive,
122
- measurement.inclusive
123
- );
117
+ var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
124
118
  var cleanComponents;
125
119
 
126
120
  if (onlyClean) {
@@ -162,7 +156,7 @@ function getInclusiveSummary(measurements, onlyClean) {
162
156
  }
163
157
  }
164
158
 
165
- arr.sort(function(a, b) {
159
+ arr.sort(function (a, b) {
166
160
  return b.time - a.time;
167
161
  });
168
162
 
@@ -201,4 +195,4 @@ var ReactDefaultPerfAnalysis = {
201
195
  getTotalTime: getTotalTime
202
196
  };
203
197
 
204
- module.exports = ReactDefaultPerfAnalysis;
198
+ module.exports = ReactDefaultPerfAnalysis;
@@ -35,20 +35,15 @@ function defineWarningProperty(object, key) {
35
35
  configurable: false,
36
36
  enumerable: true,
37
37
 
38
- get: function() {
38
+ get: function () {
39
39
  if (!this._store) {
40
40
  return null;
41
41
  }
42
42
  return this._store[key];
43
43
  },
44
44
 
45
- set: function(value) {
46
- ("production" !== process.env.NODE_ENV ? warning(
47
- false,
48
- 'Don\'t set the %s property of the React element. Instead, ' +
49
- 'specify the correct value when initially creating the element.',
50
- key
51
- ) : null);
45
+ set: function (value) {
46
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set the %s property of the React element. Instead, ' + 'specify the correct value when initially creating the element.', key) : undefined;
52
47
  this._store[key] = value;
53
48
  }
54
49
 
@@ -75,9 +70,7 @@ function defineMutationMembrane(prototype) {
75
70
  defineWarningProperty(prototype, key);
76
71
  }
77
72
  useMutationMembrane = true;
78
- } catch (x) {
79
- // IE will fail on defineProperty
80
- }
73
+ } catch (x) {}
81
74
  }
82
75
 
83
76
  /**
@@ -90,7 +83,7 @@ function defineMutationMembrane(prototype) {
90
83
  * @param {*} props
91
84
  * @internal
92
85
  */
93
- var ReactElement = function(type, key, ref, owner, context, props) {
86
+ var ReactElement = function (type, key, ref, owner, context, props) {
94
87
  // Built-in properties that belong on the element
95
88
  this.type = type;
96
89
  this.key = key;
@@ -99,16 +92,12 @@ var ReactElement = function(type, key, ref, owner, context, props) {
99
92
  // Record the component responsible for creating this element.
100
93
  this._owner = owner;
101
94
 
102
- // TODO: Deprecate withContext, and then the context becomes accessible
103
- // through the owner.
104
- this._context = context;
105
-
106
- if ("production" !== process.env.NODE_ENV) {
95
+ if ('production' !== process.env.NODE_ENV) {
107
96
  // The validation flag and props are currently mutative. We put them on
108
97
  // an external backing store so that we can freeze the whole object.
109
98
  // This can be replaced with a WeakMap once they are implemented in
110
99
  // commonly used development environments.
111
- this._store = {props: props, originalProps: assign({}, props)};
100
+ this._store = { props: props, originalProps: assign({}, props) };
112
101
 
113
102
  // To make comparing ReactElements easier for testing purposes, we make
114
103
  // the validation flag non-enumerable (where possible, which should
@@ -120,8 +109,7 @@ var ReactElement = function(type, key, ref, owner, context, props) {
120
109
  enumerable: false,
121
110
  writable: true
122
111
  });
123
- } catch (x) {
124
- }
112
+ } catch (x) {}
125
113
  this._store.validated = false;
126
114
 
127
115
  // We're not allowed to set props directly on the object so we early
@@ -142,11 +130,11 @@ ReactElement.prototype = {
142
130
  _isReactElement: true
143
131
  };
144
132
 
145
- if ("production" !== process.env.NODE_ENV) {
133
+ if ('production' !== process.env.NODE_ENV) {
146
134
  defineMutationMembrane(ReactElement.prototype);
147
135
  }
148
136
 
149
- ReactElement.createElement = function(type, config, children) {
137
+ ReactElement.createElement = function (type, config, children) {
150
138
  var propName;
151
139
 
152
140
  // Reserved names are extracted
@@ -160,8 +148,7 @@ ReactElement.createElement = function(type, config, children) {
160
148
  key = config.key === undefined ? null : '' + config.key;
161
149
  // Remaining properties are added to a new props object
162
150
  for (propName in config) {
163
- if (config.hasOwnProperty(propName) &&
164
- !RESERVED_PROPS.hasOwnProperty(propName)) {
151
+ if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
165
152
  props[propName] = config[propName];
166
153
  }
167
154
  }
@@ -190,20 +177,13 @@ ReactElement.createElement = function(type, config, children) {
190
177
  }
191
178
  }
192
179
 
193
- return new ReactElement(
194
- type,
195
- key,
196
- ref,
197
- ReactCurrentOwner.current,
198
- ReactContext.current,
199
- props
200
- );
180
+ return new ReactElement(type, key, ref, ReactCurrentOwner.current, ReactContext.current, props);
201
181
  };
202
182
 
203
- ReactElement.createFactory = function(type) {
183
+ ReactElement.createFactory = function (type) {
204
184
  var factory = ReactElement.createElement.bind(null, type);
205
185
  // Expose the type on the factory and the prototype so that it can be
206
- // easily accessed on elements. E.g. <Foo />.type === Foo.type.
186
+ // easily accessed on elements. E.g. `<Foo />.type === Foo`.
207
187
  // This should not be named `constructor` since this may not be the function
208
188
  // that created the element, and it may not even be a constructor.
209
189
  // Legacy hook TODO: Warn if this is accessed
@@ -211,24 +191,17 @@ ReactElement.createFactory = function(type) {
211
191
  return factory;
212
192
  };
213
193
 
214
- ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
215
- var newElement = new ReactElement(
216
- oldElement.type,
217
- oldElement.key,
218
- oldElement.ref,
219
- oldElement._owner,
220
- oldElement._context,
221
- newProps
222
- );
223
-
224
- if ("production" !== process.env.NODE_ENV) {
194
+ ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
195
+ var newElement = new ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, oldElement._context, newProps);
196
+
197
+ if ('production' !== process.env.NODE_ENV) {
225
198
  // If the key on the original is valid, then the clone is valid
226
199
  newElement._store.validated = oldElement._store.validated;
227
200
  }
228
201
  return newElement;
229
202
  };
230
203
 
231
- ReactElement.cloneElement = function(element, config, children) {
204
+ ReactElement.cloneElement = function (element, config, children) {
232
205
  var propName;
233
206
 
234
207
  // Original props are copied
@@ -252,8 +225,7 @@ ReactElement.cloneElement = function(element, config, children) {
252
225
  }
253
226
  // Remaining properties override existing props
254
227
  for (propName in config) {
255
- if (config.hasOwnProperty(propName) &&
256
- !RESERVED_PROPS.hasOwnProperty(propName)) {
228
+ if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
257
229
  props[propName] = config[propName];
258
230
  }
259
231
  }
@@ -272,14 +244,7 @@ ReactElement.cloneElement = function(element, config, children) {
272
244
  props.children = childArray;
273
245
  }
274
246
 
275
- return new ReactElement(
276
- element.type,
277
- key,
278
- ref,
279
- owner,
280
- element._context,
281
- props
282
- );
247
+ return new ReactElement(element.type, key, ref, owner, element._context, props);
283
248
  };
284
249
 
285
250
  /**
@@ -287,7 +252,7 @@ ReactElement.cloneElement = function(element, config, children) {
287
252
  * @return {boolean} True if `object` is a valid component.
288
253
  * @final
289
254
  */
290
- ReactElement.isValidElement = function(object) {
255
+ ReactElement.isValidElement = function (object) {
291
256
  // ReactTestUtils is often used outside of beforeEach where as React is
292
257
  // within it. This leads to two different instances of React on the same
293
258
  // page. To identify a element from a different React instance we use
@@ -302,3 +267,5 @@ ReactElement.isValidElement = function(object) {
302
267
  };
303
268
 
304
269
  module.exports = ReactElement;
270
+
271
+ // IE will fail on defineProperty
@@ -76,9 +76,7 @@ function getName(instance) {
76
76
  */
77
77
  function getCurrentOwnerDisplayName() {
78
78
  var current = ReactCurrentOwner.current;
79
- return (
80
- current && getName(current) || undefined
81
- );
79
+ return current && getName(current) || undefined;
82
80
  }
83
81
 
84
82
  /**
@@ -97,11 +95,7 @@ function validateExplicitKey(element, parentType) {
97
95
  }
98
96
  element._store.validated = true;
99
97
 
100
- warnAndMonitorForKeyUse(
101
- 'Each child in an array or iterator should have a unique "key" prop.',
102
- element,
103
- parentType
104
- );
98
+ warnAndMonitorForKeyUse('Each child in an array or iterator should have a unique "key" prop.', element, parentType);
105
99
  }
106
100
 
107
101
  /**
@@ -117,11 +111,7 @@ function validatePropertyKey(name, element, parentType) {
117
111
  if (!NUMERIC_PROPERTY_REGEX.test(name)) {
118
112
  return;
119
113
  }
120
- warnAndMonitorForKeyUse(
121
- 'Child objects should have non-numeric keys so ordering is preserved.',
122
- element,
123
- parentType
124
- );
114
+ warnAndMonitorForKeyUse('Child objects should have non-numeric keys so ordering is preserved.', element, parentType);
125
115
  }
126
116
 
127
117
  /**
@@ -134,42 +124,29 @@ function validatePropertyKey(name, element, parentType) {
134
124
  */
135
125
  function warnAndMonitorForKeyUse(message, element, parentType) {
136
126
  var ownerName = getCurrentOwnerDisplayName();
137
- var parentName = typeof parentType === 'string' ?
138
- parentType : parentType.displayName || parentType.name;
127
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
139
128
 
140
129
  var useName = ownerName || parentName;
141
- var memoizer = ownerHasKeyUseWarning[message] || (
142
- (ownerHasKeyUseWarning[message] = {})
143
- );
130
+ var memoizer = ownerHasKeyUseWarning[message] || (ownerHasKeyUseWarning[message] = {});
144
131
  if (memoizer.hasOwnProperty(useName)) {
145
132
  return;
146
133
  }
147
134
  memoizer[useName] = true;
148
135
 
149
- var parentOrOwnerAddendum =
150
- ownerName ? (" Check the render method of " + ownerName + ".") :
151
- parentName ? (" Check the React.render call using <" + parentName + ">.") :
152
- '';
136
+ var parentOrOwnerAddendum = ownerName ? ' Check the render method of ' + ownerName + '.' : parentName ? ' Check the React.render call using <' + parentName + '>.' : '';
153
137
 
154
138
  // Usually the current owner is the offender, but if it accepts children as a
155
139
  // property, it may be the creator of the child that's responsible for
156
140
  // assigning it a key.
157
141
  var childOwnerAddendum = '';
158
- if (element &&
159
- element._owner &&
160
- element._owner !== ReactCurrentOwner.current) {
142
+ if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
161
143
  // Name of the component that originally created this child.
162
144
  var childOwnerName = getName(element._owner);
163
145
 
164
- childOwnerAddendum = (" It was passed a child from " + childOwnerName + ".");
146
+ childOwnerAddendum = ' It was passed a child from ' + childOwnerName + '.';
165
147
  }
166
148
 
167
- ("production" !== process.env.NODE_ENV ? warning(
168
- false,
169
- message + '%s%s See http://fb.me/react-warning-keys for more information.',
170
- parentOrOwnerAddendum,
171
- childOwnerAddendum
172
- ) : null);
149
+ 'production' !== process.env.NODE_ENV ? warning(false, message + '%s%s See https://fb.me/react-warning-keys for more information.', parentOrOwnerAddendum, childOwnerAddendum) : undefined;
173
150
  }
174
151
 
175
152
  /**
@@ -235,25 +212,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
235
212
  try {
236
213
  // This is intentionally an invariant that gets caught. It's the same
237
214
  // behavior as without this statement except with a better message.
238
- ("production" !== process.env.NODE_ENV ? invariant(
239
- typeof propTypes[propName] === 'function',
240
- '%s: %s type `%s` is invalid; it must be a function, usually from ' +
241
- 'React.PropTypes.',
242
- componentName || 'React class',
243
- ReactPropTypeLocationNames[location],
244
- propName
245
- ) : invariant(typeof propTypes[propName] === 'function'));
215
+ !(typeof propTypes[propName] === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
246
216
  error = propTypes[propName](props, propName, componentName, location);
247
217
  } catch (ex) {
248
218
  error = ex;
249
219
  }
220
+ 'production' !== process.env.NODE_ENV ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : undefined;
250
221
  if (error instanceof Error && !(error.message in loggedTypeFailures)) {
251
222
  // Only monitor this failure once because there tends to be a lot of the
252
223
  // same error.
253
224
  loggedTypeFailures[error.message] = true;
254
225
 
255
- var addendum = getDeclarationErrorAddendum(this);
256
- ("production" !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null);
226
+ var addendum = getDeclarationErrorAddendum();
227
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
257
228
  }
258
229
  }
259
230
  }
@@ -270,8 +241,7 @@ var warnedPropsMutations = {};
270
241
  function warnForPropsMutation(propName, element) {
271
242
  var type = element.type;
272
243
  var elementName = typeof type === 'string' ? type : type.displayName;
273
- var ownerName = element._owner ?
274
- element._owner.getPublicInstance().constructor.displayName : null;
244
+ var ownerName = element._owner ? element._owner.getPublicInstance().constructor.displayName : null;
275
245
 
276
246
  var warningKey = propName + '|' + elementName + '|' + ownerName;
277
247
  if (warnedPropsMutations.hasOwnProperty(warningKey)) {
@@ -288,15 +258,7 @@ function warnForPropsMutation(propName, element) {
288
258
  ownerInfo = ' The element was created by ' + ownerName + '.';
289
259
  }
290
260
 
291
- ("production" !== process.env.NODE_ENV ? warning(
292
- false,
293
- 'Don\'t set .props.%s of the React component%s. Instead, specify the ' +
294
- 'correct value when initially creating the element or use ' +
295
- 'React.cloneElement to make a new element with updated props.%s',
296
- propName,
297
- elementInfo,
298
- ownerInfo
299
- ) : null);
261
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set .props.%s of the React component%s. Instead, specify the ' + 'correct value when initially creating the element or use ' + 'React.cloneElement to make a new element with updated props.%s', propName, elementInfo, ownerInfo) : undefined;
300
262
  }
301
263
 
302
264
  // Inline Object.is polyfill
@@ -332,8 +294,7 @@ function checkAndWarnForMutatedProps(element) {
332
294
 
333
295
  for (var propName in props) {
334
296
  if (props.hasOwnProperty(propName)) {
335
- if (!originalProps.hasOwnProperty(propName) ||
336
- !is(originalProps[propName], props[propName])) {
297
+ if (!originalProps.hasOwnProperty(propName) || !is(originalProps[propName], props[propName])) {
337
298
  warnForPropsMutation(propName, element);
338
299
 
339
300
  // Copy over the new value so that the two props objects match again
@@ -350,7 +311,7 @@ function checkAndWarnForMutatedProps(element) {
350
311
  * @param {ReactElement} element
351
312
  */
352
313
  function validatePropTypes(element) {
353
- if (element.type == null) {
314
+ if (!(typeof element.type === 'string' || typeof element.type === 'function')) {
354
315
  // This has already warned. Don't throw.
355
316
  return;
356
317
  }
@@ -358,24 +319,13 @@ function validatePropTypes(element) {
358
319
  // to a composite class which may have propTypes.
359
320
  // TODO: Validating a string's propTypes is not decoupled from the
360
321
  // rendering target which is problematic.
361
- var componentClass = ReactNativeComponent.getComponentClassForElement(
362
- element
363
- );
322
+ var componentClass = ReactNativeComponent.getComponentClassForElement(element);
364
323
  var name = componentClass.displayName || componentClass.name;
365
324
  if (componentClass.propTypes) {
366
- checkPropTypes(
367
- name,
368
- componentClass.propTypes,
369
- element.props,
370
- ReactPropTypeLocations.prop
371
- );
325
+ checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
372
326
  }
373
327
  if (typeof componentClass.getDefaultProps === 'function') {
374
- ("production" !== process.env.NODE_ENV ? warning(
375
- componentClass.getDefaultProps.isReactClassApproved,
376
- 'getDefaultProps is only used on classic React.createClass ' +
377
- 'definitions. Use a static property named `defaultProps` instead.'
378
- ) : null);
328
+ 'production' !== process.env.NODE_ENV ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined;
379
329
  }
380
330
  }
381
331
 
@@ -383,15 +333,10 @@ var ReactElementValidator = {
383
333
 
384
334
  checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
385
335
 
386
- createElement: function(type, props, children) {
336
+ createElement: function (type, props, children) {
387
337
  // We warn in this case but don't throw. We expect the element creation to
388
338
  // succeed and there will likely be errors in render.
389
- ("production" !== process.env.NODE_ENV ? warning(
390
- type != null,
391
- 'React.createElement: type should not be null or undefined. It should ' +
392
- 'be a string (for DOM elements) or a ReactClass (for composite ' +
393
- 'components).'
394
- ) : null);
339
+ 'production' !== process.env.NODE_ENV ? warning(typeof type === 'string' || typeof type === 'function', 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined;
395
340
 
396
341
  var element = ReactElement.createElement.apply(this, arguments);
397
342
 
@@ -410,44 +355,30 @@ var ReactElementValidator = {
410
355
  return element;
411
356
  },
412
357
 
413
- createFactory: function(type) {
414
- var validatedFactory = ReactElementValidator.createElement.bind(
415
- null,
416
- type
417
- );
358
+ createFactory: function (type) {
359
+ var validatedFactory = ReactElementValidator.createElement.bind(null, type);
418
360
  // Legacy hook TODO: Warn if this is accessed
419
361
  validatedFactory.type = type;
420
362
 
421
- if ("production" !== process.env.NODE_ENV) {
363
+ if ('production' !== process.env.NODE_ENV) {
422
364
  try {
423
- Object.defineProperty(
424
- validatedFactory,
425
- 'type',
426
- {
427
- enumerable: false,
428
- get: function() {
429
- ("production" !== process.env.NODE_ENV ? warning(
430
- false,
431
- 'Factory.type is deprecated. Access the class directly ' +
432
- 'before passing it to createFactory.'
433
- ) : null);
434
- Object.defineProperty(this, 'type', {
435
- value: type
436
- });
437
- return type;
438
- }
365
+ Object.defineProperty(validatedFactory, 'type', {
366
+ enumerable: false,
367
+ get: function () {
368
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
369
+ Object.defineProperty(this, 'type', {
370
+ value: type
371
+ });
372
+ return type;
439
373
  }
440
- );
441
- } catch (x) {
442
- // IE will fail on defineProperty (es5-shim/sham too)
443
- }
374
+ });
375
+ } catch (x) {}
444
376
  }
445
377
 
446
-
447
378
  return validatedFactory;
448
379
  },
449
380
 
450
- cloneElement: function(element, props, children) {
381
+ cloneElement: function (element, props, children) {
451
382
  var newElement = ReactElement.cloneElement.apply(this, arguments);
452
383
  for (var i = 2; i < arguments.length; i++) {
453
384
  validateChildKeys(arguments[i], newElement.type);
@@ -459,3 +390,5 @@ var ReactElementValidator = {
459
390
  };
460
391
 
461
392
  module.exports = ReactElementValidator;
393
+
394
+ // IE will fail on defineProperty (es5-shim/sham too)