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
@@ -134,10 +134,7 @@ function enqueueTextContent(parentID, textContent) {
134
134
  */
135
135
  function processQueue() {
136
136
  if (updateQueue.length) {
137
- ReactComponentEnvironment.processChildrenUpdates(
138
- updateQueue,
139
- markupQueue
140
- );
137
+ ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);
141
138
  clearQueue();
142
139
  }
143
140
  }
@@ -177,10 +174,8 @@ var ReactMultiChild = {
177
174
  * @return {array} An array of mounted representations.
178
175
  * @internal
179
176
  */
180
- mountChildren: function(nestedChildren, transaction, context) {
181
- var children = ReactChildReconciler.instantiateChildren(
182
- nestedChildren, transaction, context
183
- );
177
+ mountChildren: function (nestedChildren, transaction, context) {
178
+ var children = ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
184
179
  this._renderedChildren = children;
185
180
  var mountImages = [];
186
181
  var index = 0;
@@ -189,12 +184,7 @@ var ReactMultiChild = {
189
184
  var child = children[name];
190
185
  // Inlined for performance, see `ReactInstanceHandles.createReactID`.
191
186
  var rootID = this._rootNodeID + name;
192
- var mountImage = ReactReconciler.mountComponent(
193
- child,
194
- rootID,
195
- transaction,
196
- context
197
- );
187
+ var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
198
188
  child._mountIndex = index;
199
189
  mountImages.push(mountImage);
200
190
  index++;
@@ -209,7 +199,7 @@ var ReactMultiChild = {
209
199
  * @param {string} nextContent String of content.
210
200
  * @internal
211
201
  */
212
- updateTextContent: function(nextContent) {
202
+ updateTextContent: function (nextContent) {
213
203
  updateDepth++;
214
204
  var errorThrown = true;
215
205
  try {
@@ -244,7 +234,7 @@ var ReactMultiChild = {
244
234
  * @param {ReactReconcileTransaction} transaction
245
235
  * @internal
246
236
  */
247
- updateChildren: function(nextNestedChildren, transaction, context) {
237
+ updateChildren: function (nextNestedChildren, transaction, context) {
248
238
  updateDepth++;
249
239
  var errorThrown = true;
250
240
  try {
@@ -259,7 +249,6 @@ var ReactMultiChild = {
259
249
  processQueue();
260
250
  }
261
251
  }
262
-
263
252
  }
264
253
  },
265
254
 
@@ -272,11 +261,9 @@ var ReactMultiChild = {
272
261
  * @final
273
262
  * @protected
274
263
  */
275
- _updateChildren: function(nextNestedChildren, transaction, context) {
264
+ _updateChildren: function (nextNestedChildren, transaction, context) {
276
265
  var prevChildren = this._renderedChildren;
277
- var nextChildren = ReactChildReconciler.updateChildren(
278
- prevChildren, nextNestedChildren, transaction, context
279
- );
266
+ var nextChildren = ReactChildReconciler.updateChildren(prevChildren, nextNestedChildren, transaction, context);
280
267
  this._renderedChildren = nextChildren;
281
268
  if (!nextChildren && !prevChildren) {
282
269
  return;
@@ -303,16 +290,13 @@ var ReactMultiChild = {
303
290
  this._unmountChildByName(prevChild, name);
304
291
  }
305
292
  // The child must be instantiated before it's mounted.
306
- this._mountChildByNameAtIndex(
307
- nextChild, name, nextIndex, transaction, context
308
- );
293
+ this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context);
309
294
  }
310
295
  nextIndex++;
311
296
  }
312
297
  // Remove children that are no longer present.
313
298
  for (name in prevChildren) {
314
- if (prevChildren.hasOwnProperty(name) &&
315
- !(nextChildren && nextChildren.hasOwnProperty(name))) {
299
+ if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
316
300
  this._unmountChildByName(prevChildren[name], name);
317
301
  }
318
302
  }
@@ -324,7 +308,7 @@ var ReactMultiChild = {
324
308
  *
325
309
  * @internal
326
310
  */
327
- unmountChildren: function() {
311
+ unmountChildren: function () {
328
312
  var renderedChildren = this._renderedChildren;
329
313
  ReactChildReconciler.unmountChildren(renderedChildren);
330
314
  this._renderedChildren = null;
@@ -338,7 +322,7 @@ var ReactMultiChild = {
338
322
  * @param {number} lastIndex Last index visited of the siblings of `child`.
339
323
  * @protected
340
324
  */
341
- moveChild: function(child, toIndex, lastIndex) {
325
+ moveChild: function (child, toIndex, lastIndex) {
342
326
  // If the index of `child` is less than `lastIndex`, then it needs to
343
327
  // be moved. Otherwise, we do not need to move it because a child will be
344
328
  // inserted or moved before `child`.
@@ -354,7 +338,7 @@ var ReactMultiChild = {
354
338
  * @param {string} mountImage Markup to insert.
355
339
  * @protected
356
340
  */
357
- createChild: function(child, mountImage) {
341
+ createChild: function (child, mountImage) {
358
342
  enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
359
343
  },
360
344
 
@@ -364,7 +348,7 @@ var ReactMultiChild = {
364
348
  * @param {ReactComponent} child Child to remove.
365
349
  * @protected
366
350
  */
367
- removeChild: function(child) {
351
+ removeChild: function (child) {
368
352
  enqueueRemove(this._rootNodeID, child._mountIndex);
369
353
  },
370
354
 
@@ -374,7 +358,7 @@ var ReactMultiChild = {
374
358
  * @param {string} textContent Text content to set.
375
359
  * @protected
376
360
  */
377
- setTextContent: function(textContent) {
361
+ setTextContent: function (textContent) {
378
362
  enqueueTextContent(this._rootNodeID, textContent);
379
363
  },
380
364
 
@@ -389,20 +373,10 @@ var ReactMultiChild = {
389
373
  * @param {ReactReconcileTransaction} transaction
390
374
  * @private
391
375
  */
392
- _mountChildByNameAtIndex: function(
393
- child,
394
- name,
395
- index,
396
- transaction,
397
- context) {
376
+ _mountChildByNameAtIndex: function (child, name, index, transaction, context) {
398
377
  // Inlined for performance, see `ReactInstanceHandles.createReactID`.
399
378
  var rootID = this._rootNodeID + name;
400
- var mountImage = ReactReconciler.mountComponent(
401
- child,
402
- rootID,
403
- transaction,
404
- context
405
- );
379
+ var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
406
380
  child._mountIndex = index;
407
381
  this.createChild(child, mountImage);
408
382
  },
@@ -416,7 +390,7 @@ var ReactMultiChild = {
416
390
  * @param {string} name Name of the child in `this._renderedChildren`.
417
391
  * @private
418
392
  */
419
- _unmountChildByName: function(child, name) {
393
+ _unmountChildByName: function (child, name) {
420
394
  this.removeChild(child);
421
395
  child._mountIndex = null;
422
396
  }
@@ -425,4 +399,4 @@ var ReactMultiChild = {
425
399
 
426
400
  };
427
401
 
428
- module.exports = ReactMultiChild;
402
+ module.exports = ReactMultiChild;
@@ -28,4 +28,4 @@ var ReactMultiChildUpdateTypes = keyMirror({
28
28
  TEXT_CONTENT: null
29
29
  });
30
30
 
31
- module.exports = ReactMultiChildUpdateTypes;
31
+ module.exports = ReactMultiChildUpdateTypes;
@@ -16,29 +16,29 @@ var invariant = require("./invariant");
16
16
 
17
17
  var autoGenerateWrapperClass = null;
18
18
  var genericComponentClass = null;
19
- // This registry keeps track of wrapper classes around native tags
19
+ // This registry keeps track of wrapper classes around native tags.
20
20
  var tagToComponentClass = {};
21
21
  var textComponentClass = null;
22
22
 
23
23
  var ReactNativeComponentInjection = {
24
24
  // This accepts a class that receives the tag string. This is a catch all
25
25
  // that can render any kind of tag.
26
- injectGenericComponentClass: function(componentClass) {
26
+ injectGenericComponentClass: function (componentClass) {
27
27
  genericComponentClass = componentClass;
28
28
  },
29
29
  // This accepts a text component class that takes the text string to be
30
30
  // rendered as props.
31
- injectTextComponentClass: function(componentClass) {
31
+ injectTextComponentClass: function (componentClass) {
32
32
  textComponentClass = componentClass;
33
33
  },
34
34
  // This accepts a keyed object with classes as values. Each key represents a
35
35
  // tag. That particular tag will use this class instead of the generic one.
36
- injectComponentClasses: function(componentClasses) {
36
+ injectComponentClasses: function (componentClasses) {
37
37
  assign(tagToComponentClass, componentClasses);
38
38
  },
39
39
  // Temporary hack since we expect DOM refs to behave like composites,
40
40
  // for this release.
41
- injectAutoWrapper: function(wrapperFactory) {
41
+ injectAutoWrapper: function (wrapperFactory) {
42
42
  autoGenerateWrapperClass = wrapperFactory;
43
43
  }
44
44
  };
@@ -68,11 +68,7 @@ function getComponentClassForElement(element) {
68
68
  * @return {function} The internal class constructor function.
69
69
  */
70
70
  function createInternalComponent(element) {
71
- ("production" !== process.env.NODE_ENV ? invariant(
72
- genericComponentClass,
73
- 'There is no registered component for the tag %s',
74
- element.type
75
- ) : invariant(genericComponentClass));
71
+ !genericComponentClass ? 'production' !== process.env.NODE_ENV ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
76
72
  return new genericComponentClass(element.type, element.props);
77
73
  }
78
74
 
@@ -100,4 +96,4 @@ var ReactNativeComponent = {
100
96
  injection: ReactNativeComponentInjection
101
97
  };
102
98
 
103
- module.exports = ReactNativeComponent;
99
+ module.exports = ReactNativeComponent;
package/lib/ReactOwner.js CHANGED
@@ -50,11 +50,8 @@ var ReactOwner = {
50
50
  * @return {boolean} True if `object` is a valid owner.
51
51
  * @final
52
52
  */
53
- isValidOwner: function(object) {
54
- return !!(
55
- (object &&
56
- typeof object.attachRef === 'function' && typeof object.detachRef === 'function')
57
- );
53
+ isValidOwner: function (object) {
54
+ return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function');
58
55
  },
59
56
 
60
57
  /**
@@ -66,15 +63,8 @@ var ReactOwner = {
66
63
  * @final
67
64
  * @internal
68
65
  */
69
- addComponentAsRefTo: function(component, ref, owner) {
70
- ("production" !== process.env.NODE_ENV ? invariant(
71
- ReactOwner.isValidOwner(owner),
72
- 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
73
- 'usually means that you\'re trying to add a ref to a component that ' +
74
- 'doesn\'t have an owner (that is, was not created inside of another ' +
75
- 'component\'s `render` method). Try rendering this component inside of ' +
76
- 'a new top-level component which will hold the ref.'
77
- ) : invariant(ReactOwner.isValidOwner(owner)));
66
+ addComponentAsRefTo: function (component, ref, owner) {
67
+ !ReactOwner.isValidOwner(owner) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to add a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
78
68
  owner.attachRef(ref, component);
79
69
  },
80
70
 
@@ -87,15 +77,8 @@ var ReactOwner = {
87
77
  * @final
88
78
  * @internal
89
79
  */
90
- removeComponentAsRefFrom: function(component, ref, owner) {
91
- ("production" !== process.env.NODE_ENV ? invariant(
92
- ReactOwner.isValidOwner(owner),
93
- 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
94
- 'usually means that you\'re trying to remove a ref to a component that ' +
95
- 'doesn\'t have an owner (that is, was not created inside of another ' +
96
- 'component\'s `render` method). Try rendering this component inside of ' +
97
- 'a new top-level component which will hold the ref.'
98
- ) : invariant(ReactOwner.isValidOwner(owner)));
80
+ removeComponentAsRefFrom: function (component, ref, owner) {
81
+ !ReactOwner.isValidOwner(owner) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to remove a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
99
82
  // Check that `component` is still the current ref because we do not want to
100
83
  // detach the ref if another component stole it.
101
84
  if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
@@ -105,4 +88,4 @@ var ReactOwner = {
105
88
 
106
89
  };
107
90
 
108
- module.exports = ReactOwner;
91
+ module.exports = ReactOwner;
package/lib/ReactPerf.js CHANGED
@@ -34,17 +34,13 @@ var ReactPerf = {
34
34
  * @param {string} objectName
35
35
  * @param {object<string>} methodNames
36
36
  */
37
- measureMethods: function(object, objectName, methodNames) {
38
- if ("production" !== process.env.NODE_ENV) {
37
+ measureMethods: function (object, objectName, methodNames) {
38
+ if ('production' !== process.env.NODE_ENV) {
39
39
  for (var key in methodNames) {
40
40
  if (!methodNames.hasOwnProperty(key)) {
41
41
  continue;
42
42
  }
43
- object[key] = ReactPerf.measure(
44
- objectName,
45
- methodNames[key],
46
- object[key]
47
- );
43
+ object[key] = ReactPerf.measure(objectName, methodNames[key], object[key]);
48
44
  }
49
45
  }
50
46
  },
@@ -57,10 +53,10 @@ var ReactPerf = {
57
53
  * @param {function} func
58
54
  * @return {function}
59
55
  */
60
- measure: function(objName, fnName, func) {
61
- if ("production" !== process.env.NODE_ENV) {
56
+ measure: function (objName, fnName, func) {
57
+ if ('production' !== process.env.NODE_ENV) {
62
58
  var measuredFunc = null;
63
- var wrapper = function() {
59
+ var wrapper = function () {
64
60
  if (ReactPerf.enableMeasure) {
65
61
  if (!measuredFunc) {
66
62
  measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
@@ -79,7 +75,7 @@ var ReactPerf = {
79
75
  /**
80
76
  * @param {function} measure
81
77
  */
82
- injectMeasure: function(measure) {
78
+ injectMeasure: function (measure) {
83
79
  ReactPerf.storedMeasure = measure;
84
80
  }
85
81
  }
@@ -97,4 +93,4 @@ function _noMeasure(objName, fnName, func) {
97
93
  return func;
98
94
  }
99
95
 
100
- module.exports = ReactPerf;
96
+ module.exports = ReactPerf;
@@ -23,7 +23,7 @@ var joinClasses = require("./joinClasses");
23
23
  * @return {function}
24
24
  */
25
25
  function createTransferStrategy(mergeStrategy) {
26
- return function(props, key, value) {
26
+ return function (props, key, value) {
27
27
  if (!props.hasOwnProperty(key)) {
28
28
  props[key] = value;
29
29
  } else {
@@ -32,7 +32,7 @@ function createTransferStrategy(mergeStrategy) {
32
32
  };
33
33
  }
34
34
 
35
- var transferStrategyMerge = createTransferStrategy(function(a, b) {
35
+ var transferStrategyMerge = createTransferStrategy(function (a, b) {
36
36
  // `merge` overrides the first object's (`props[key]` above) keys using the
37
37
  // second object's (`value`) keys. An object's style's existing `propA` would
38
38
  // get overridden. Flip the order here.
@@ -99,10 +99,10 @@ var ReactPropTransferer = {
99
99
  * @param {object} newProps new props to merge in
100
100
  * @return {object} a new object containing both sets of props merged.
101
101
  */
102
- mergeProps: function(oldProps, newProps) {
102
+ mergeProps: function (oldProps, newProps) {
103
103
  return transferInto(assign({}, oldProps), newProps);
104
104
  }
105
105
 
106
106
  };
107
107
 
108
- module.exports = ReactPropTransferer;
108
+ module.exports = ReactPropTransferer;
@@ -13,7 +13,7 @@
13
13
 
14
14
  var ReactPropTypeLocationNames = {};
15
15
 
16
- if ("production" !== process.env.NODE_ENV) {
16
+ if ('production' !== process.env.NODE_ENV) {
17
17
  ReactPropTypeLocationNames = {
18
18
  prop: 'prop',
19
19
  context: 'context',
@@ -21,4 +21,4 @@ if ("production" !== process.env.NODE_ENV) {
21
21
  };
22
22
  }
23
23
 
24
- module.exports = ReactPropTypeLocationNames;
24
+ module.exports = ReactPropTypeLocationNames;
@@ -19,4 +19,4 @@ var ReactPropTypeLocations = keyMirror({
19
19
  childContext: null
20
20
  });
21
21
 
22
- module.exports = ReactPropTypeLocations;
22
+ module.exports = ReactPropTypeLocations;
@@ -66,9 +66,6 @@ var emptyFunction = require("./emptyFunction");
66
66
 
67
67
  var ANONYMOUS = '<<anonymous>>';
68
68
 
69
- var elementTypeChecker = createElementTypeChecker();
70
- var nodeTypeChecker = createNodeChecker();
71
-
72
69
  var ReactPropTypes = {
73
70
  array: createPrimitiveTypeChecker('array'),
74
71
  bool: createPrimitiveTypeChecker('boolean'),
@@ -79,9 +76,9 @@ var ReactPropTypes = {
79
76
 
80
77
  any: createAnyTypeChecker(),
81
78
  arrayOf: createArrayOfTypeChecker,
82
- element: elementTypeChecker,
79
+ element: createElementTypeChecker(),
83
80
  instanceOf: createInstanceTypeChecker,
84
- node: nodeTypeChecker,
81
+ node: createNodeChecker(),
85
82
  objectOf: createObjectOfTypeChecker,
86
83
  oneOf: createEnumTypeChecker,
87
84
  oneOfType: createUnionTypeChecker,
@@ -89,19 +86,17 @@ var ReactPropTypes = {
89
86
  };
90
87
 
91
88
  function createChainableTypeChecker(validate) {
92
- function checkType(isRequired, props, propName, componentName, location) {
89
+ function checkType(isRequired, props, propName, componentName, location, propFullName) {
93
90
  componentName = componentName || ANONYMOUS;
91
+ propFullName = propFullName || propName;
94
92
  if (props[propName] == null) {
95
93
  var locationName = ReactPropTypeLocationNames[location];
96
94
  if (isRequired) {
97
- return new Error(
98
- ("Required " + locationName + " `" + propName + "` was not specified in ") +
99
- ("`" + componentName + "`.")
100
- );
95
+ return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
101
96
  }
102
97
  return null;
103
98
  } else {
104
- return validate(props, propName, componentName, location);
99
+ return validate(props, propName, componentName, location, propFullName);
105
100
  }
106
101
  }
107
102
 
@@ -112,7 +107,7 @@ function createChainableTypeChecker(validate) {
112
107
  }
113
108
 
114
109
  function createPrimitiveTypeChecker(expectedType) {
115
- function validate(props, propName, componentName, location) {
110
+ function validate(props, propName, componentName, location, propFullName) {
116
111
  var propValue = props[propName];
117
112
  var propType = getPropType(propValue);
118
113
  if (propType !== expectedType) {
@@ -122,10 +117,7 @@ function createPrimitiveTypeChecker(expectedType) {
122
117
  // 'of type `object`'.
123
118
  var preciseType = getPreciseType(propValue);
124
119
 
125
- return new Error(
126
- ("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
127
- ("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
128
- );
120
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
129
121
  }
130
122
  return null;
131
123
  }
@@ -137,18 +129,15 @@ function createAnyTypeChecker() {
137
129
  }
138
130
 
139
131
  function createArrayOfTypeChecker(typeChecker) {
140
- function validate(props, propName, componentName, location) {
132
+ function validate(props, propName, componentName, location, propFullName) {
141
133
  var propValue = props[propName];
142
134
  if (!Array.isArray(propValue)) {
143
135
  var locationName = ReactPropTypeLocationNames[location];
144
136
  var propType = getPropType(propValue);
145
- return new Error(
146
- ("Invalid " + locationName + " `" + propName + "` of type ") +
147
- ("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
148
- );
137
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
149
138
  }
150
139
  for (var i = 0; i < propValue.length; i++) {
151
- var error = typeChecker(propValue, i, componentName, location);
140
+ var error = typeChecker(propValue, i, componentName, location, '' + propFullName + '[' + i + ']');
152
141
  if (error instanceof Error) {
153
142
  return error;
154
143
  }
@@ -159,13 +148,10 @@ function createArrayOfTypeChecker(typeChecker) {
159
148
  }
160
149
 
161
150
  function createElementTypeChecker() {
162
- function validate(props, propName, componentName, location) {
151
+ function validate(props, propName, componentName, location, propFullName) {
163
152
  if (!ReactElement.isValidElement(props[propName])) {
164
153
  var locationName = ReactPropTypeLocationNames[location];
165
- return new Error(
166
- ("Invalid " + locationName + " `" + propName + "` supplied to ") +
167
- ("`" + componentName + "`, expected a ReactElement.")
168
- );
154
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
169
155
  }
170
156
  return null;
171
157
  }
@@ -173,14 +159,11 @@ function createElementTypeChecker() {
173
159
  }
174
160
 
175
161
  function createInstanceTypeChecker(expectedClass) {
176
- function validate(props, propName, componentName, location) {
162
+ function validate(props, propName, componentName, location, propFullName) {
177
163
  if (!(props[propName] instanceof expectedClass)) {
178
164
  var locationName = ReactPropTypeLocationNames[location];
179
165
  var expectedClassName = expectedClass.name || ANONYMOUS;
180
- return new Error(
181
- ("Invalid " + locationName + " `" + propName + "` supplied to ") +
182
- ("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
183
- );
166
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
184
167
  }
185
168
  return null;
186
169
  }
@@ -188,7 +171,13 @@ function createInstanceTypeChecker(expectedClass) {
188
171
  }
189
172
 
190
173
  function createEnumTypeChecker(expectedValues) {
191
- function validate(props, propName, componentName, location) {
174
+ if (!Array.isArray(expectedValues)) {
175
+ return createChainableTypeChecker(function () {
176
+ return new Error('Invalid argument supplied to oneOf, expected an instance of array.');
177
+ });
178
+ }
179
+
180
+ function validate(props, propName, componentName, location, propFullName) {
192
181
  var propValue = props[propName];
193
182
  for (var i = 0; i < expectedValues.length; i++) {
194
183
  if (propValue === expectedValues[i]) {
@@ -198,28 +187,22 @@ function createEnumTypeChecker(expectedValues) {
198
187
 
199
188
  var locationName = ReactPropTypeLocationNames[location];
200
189
  var valuesString = JSON.stringify(expectedValues);
201
- return new Error(
202
- ("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
203
- ("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
204
- );
190
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
205
191
  }
206
192
  return createChainableTypeChecker(validate);
207
193
  }
208
194
 
209
195
  function createObjectOfTypeChecker(typeChecker) {
210
- function validate(props, propName, componentName, location) {
196
+ function validate(props, propName, componentName, location, propFullName) {
211
197
  var propValue = props[propName];
212
198
  var propType = getPropType(propValue);
213
199
  if (propType !== 'object') {
214
200
  var locationName = ReactPropTypeLocationNames[location];
215
- return new Error(
216
- ("Invalid " + locationName + " `" + propName + "` of type ") +
217
- ("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
218
- );
201
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
219
202
  }
220
203
  for (var key in propValue) {
221
204
  if (propValue.hasOwnProperty(key)) {
222
- var error = typeChecker(propValue, key, componentName, location);
205
+ var error = typeChecker(propValue, key, componentName, location, '' + propFullName + '.' + key);
223
206
  if (error instanceof Error) {
224
207
  return error;
225
208
  }
@@ -231,31 +214,31 @@ function createObjectOfTypeChecker(typeChecker) {
231
214
  }
232
215
 
233
216
  function createUnionTypeChecker(arrayOfTypeCheckers) {
234
- function validate(props, propName, componentName, location) {
217
+ if (!Array.isArray(arrayOfTypeCheckers)) {
218
+ return createChainableTypeChecker(function () {
219
+ return new Error('Invalid argument supplied to oneOfType, expected an instance of array.');
220
+ });
221
+ }
222
+
223
+ function validate(props, propName, componentName, location, propFullName) {
235
224
  for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
236
225
  var checker = arrayOfTypeCheckers[i];
237
- if (checker(props, propName, componentName, location) == null) {
226
+ if (checker(props, propName, componentName, location, propFullName) == null) {
238
227
  return null;
239
228
  }
240
229
  }
241
230
 
242
231
  var locationName = ReactPropTypeLocationNames[location];
243
- return new Error(
244
- ("Invalid " + locationName + " `" + propName + "` supplied to ") +
245
- ("`" + componentName + "`.")
246
- );
232
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
247
233
  }
248
234
  return createChainableTypeChecker(validate);
249
235
  }
250
236
 
251
237
  function createNodeChecker() {
252
- function validate(props, propName, componentName, location) {
238
+ function validate(props, propName, componentName, location, propFullName) {
253
239
  if (!isNode(props[propName])) {
254
240
  var locationName = ReactPropTypeLocationNames[location];
255
- return new Error(
256
- ("Invalid " + locationName + " `" + propName + "` supplied to ") +
257
- ("`" + componentName + "`, expected a ReactNode.")
258
- );
241
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
259
242
  }
260
243
  return null;
261
244
  }
@@ -263,22 +246,19 @@ function createNodeChecker() {
263
246
  }
264
247
 
265
248
  function createShapeTypeChecker(shapeTypes) {
266
- function validate(props, propName, componentName, location) {
249
+ function validate(props, propName, componentName, location, propFullName) {
267
250
  var propValue = props[propName];
268
251
  var propType = getPropType(propValue);
269
252
  if (propType !== 'object') {
270
253
  var locationName = ReactPropTypeLocationNames[location];
271
- return new Error(
272
- ("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
273
- ("supplied to `" + componentName + "`, expected `object`.")
274
- );
254
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
275
255
  }
276
256
  for (var key in shapeTypes) {
277
257
  var checker = shapeTypes[key];
278
258
  if (!checker) {
279
259
  continue;
280
260
  }
281
- var error = checker(propValue, key, componentName, location);
261
+ var error = checker(propValue, key, componentName, location, '' + propFullName + '.' + key);
282
262
  if (error) {
283
263
  return error;
284
264
  }
@@ -344,4 +324,4 @@ function getPreciseType(propValue) {
344
324
  return propType;
345
325
  }
346
326
 
347
- module.exports = ReactPropTypes;
327
+ module.exports = ReactPropTypes;