react 0.14.0-beta1 → 0.14.0

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 (173) hide show
  1. package/addons.js +8 -3
  2. package/dist/react-with-addons.js +5048 -4095
  3. package/dist/react-with-addons.min.js +6 -6
  4. package/dist/react.js +4555 -3729
  5. package/dist/react.min.js +6 -5
  6. package/lib/AutoFocusUtils.js +3 -3
  7. package/lib/BeforeInputEventPlugin.js +13 -13
  8. package/lib/CSSProperty.js +18 -3
  9. package/lib/CSSPropertyOperations.js +27 -14
  10. package/lib/CallbackQueue.js +4 -4
  11. package/lib/ChangeEventPlugin.js +15 -14
  12. package/lib/DOMChildrenOperations.js +22 -7
  13. package/lib/DOMProperty.js +8 -8
  14. package/lib/DOMPropertyOperations.js +23 -10
  15. package/lib/Danger.js +21 -16
  16. package/lib/DefaultEventPluginOrder.js +2 -2
  17. package/lib/EnterLeaveEventPlugin.js +18 -10
  18. package/lib/EventConstants.js +23 -1
  19. package/lib/EventPluginHub.js +29 -21
  20. package/lib/EventPluginRegistry.js +8 -8
  21. package/lib/EventPluginUtils.js +34 -38
  22. package/lib/EventPropagators.js +8 -8
  23. package/lib/FallbackCompositionState.js +9 -3
  24. package/lib/HTMLDOMPropertyConfig.js +24 -4
  25. package/lib/LinkedStateMixin.js +2 -2
  26. package/lib/LinkedValueUtils.js +8 -8
  27. package/lib/MetaMatchers.js +118 -0
  28. package/lib/OrderedMap.js +453 -0
  29. package/lib/PooledClass.js +3 -5
  30. package/lib/React.js +18 -7
  31. package/lib/ReactBrowserComponentMixin.js +4 -4
  32. package/lib/ReactBrowserEventEmitter.js +36 -7
  33. package/lib/ReactCSSTransitionGroup.js +35 -9
  34. package/lib/ReactCSSTransitionGroupChild.js +48 -30
  35. package/lib/ReactChildReconciler.js +24 -19
  36. package/lib/ReactChildren.js +72 -32
  37. package/lib/ReactClass.js +46 -46
  38. package/lib/ReactComponent.js +18 -16
  39. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  40. package/lib/ReactComponentEnvironment.js +2 -2
  41. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  42. package/lib/ReactCompositeComponent.js +95 -44
  43. package/lib/ReactDOM.js +74 -159
  44. package/lib/ReactDOMComponent.js +235 -93
  45. package/lib/ReactDOMFactories.js +177 -0
  46. package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
  47. package/lib/ReactDOMIDOperations.js +8 -81
  48. package/lib/ReactDOMInput.js +18 -9
  49. package/lib/ReactDOMOption.js +7 -7
  50. package/lib/ReactDOMSelect.js +9 -9
  51. package/lib/ReactDOMSelection.js +19 -3
  52. package/lib/ReactDOMServer.js +5 -3
  53. package/lib/ReactDOMTextComponent.js +33 -20
  54. package/lib/ReactDOMTextarea.js +14 -12
  55. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  56. package/lib/ReactDefaultInjection.js +23 -25
  57. package/lib/ReactDefaultPerf.js +17 -11
  58. package/lib/ReactDefaultPerfAnalysis.js +13 -12
  59. package/lib/ReactElement.js +85 -39
  60. package/lib/ReactElementValidator.js +47 -90
  61. package/lib/ReactEmptyComponent.js +26 -62
  62. package/lib/ReactEmptyComponentRegistry.js +48 -0
  63. package/lib/ReactErrorUtils.js +53 -9
  64. package/lib/ReactEventEmitterMixin.js +2 -2
  65. package/lib/ReactEventListener.js +33 -21
  66. package/lib/ReactFragment.js +27 -118
  67. package/lib/ReactInjection.js +10 -12
  68. package/lib/ReactInputSelection.js +4 -4
  69. package/lib/ReactInstanceHandles.js +10 -11
  70. package/lib/ReactIsomorphic.js +15 -11
  71. package/lib/ReactLink.js +2 -2
  72. package/lib/ReactMarkupChecksum.js +6 -2
  73. package/lib/ReactMount.js +186 -85
  74. package/lib/ReactMultiChild.js +119 -25
  75. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  76. package/lib/ReactNativeComponent.js +3 -3
  77. package/lib/ReactNoopUpdateQueue.js +3 -3
  78. package/lib/ReactOwner.js +3 -3
  79. package/lib/ReactPerf.js +2 -2
  80. package/lib/ReactPropTransferer.js +3 -3
  81. package/lib/ReactPropTypeLocationNames.js +1 -1
  82. package/lib/ReactPropTypeLocations.js +1 -1
  83. package/lib/ReactPropTypes.js +38 -9
  84. package/lib/ReactReconcileTransaction.js +10 -8
  85. package/lib/ReactReconciler.js +5 -6
  86. package/lib/ReactRef.js +14 -2
  87. package/lib/ReactServerBatchingStrategy.js +5 -5
  88. package/lib/ReactServerRendering.js +12 -12
  89. package/lib/ReactServerRenderingTransaction.js +6 -5
  90. package/lib/ReactTestUtils.js +47 -39
  91. package/lib/ReactTransitionChildMapping.js +3 -6
  92. package/lib/ReactTransitionEvents.js +1 -1
  93. package/lib/ReactTransitionGroup.js +5 -6
  94. package/lib/ReactUpdateQueue.js +19 -19
  95. package/lib/ReactUpdates.js +15 -15
  96. package/lib/{performance.js → ReactVersion.js} +3 -12
  97. package/lib/ReactWithAddons.js +24 -15
  98. package/lib/ResponderEventPlugin.js +514 -0
  99. package/lib/ResponderSyntheticEvent.js +40 -0
  100. package/lib/ResponderTouchHistoryStore.js +180 -0
  101. package/lib/SVGDOMPropertyConfig.js +1 -1
  102. package/lib/SelectEventPlugin.js +19 -9
  103. package/lib/SimpleEventPlugin.js +198 -43
  104. package/lib/SyntheticClipboardEvent.js +1 -1
  105. package/lib/SyntheticCompositionEvent.js +1 -1
  106. package/lib/SyntheticDragEvent.js +1 -1
  107. package/lib/SyntheticEvent.js +18 -4
  108. package/lib/SyntheticFocusEvent.js +1 -1
  109. package/lib/SyntheticInputEvent.js +1 -1
  110. package/lib/SyntheticKeyboardEvent.js +4 -4
  111. package/lib/SyntheticMouseEvent.js +3 -3
  112. package/lib/SyntheticTouchEvent.js +2 -2
  113. package/lib/SyntheticUIEvent.js +2 -2
  114. package/lib/SyntheticWheelEvent.js +1 -1
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +7 -7
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -7
  120. package/lib/cloneWithProps.js +11 -6
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +7 -6
  124. package/lib/findDOMNode.js +9 -9
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/getEventKey.js +1 -1
  127. package/lib/{isTextNode.js → getTestDocument.js} +7 -11
  128. package/lib/getTextContentAccessor.js +1 -1
  129. package/lib/instantiateReactComponent.js +15 -17
  130. package/lib/isEventSupported.js +1 -1
  131. package/lib/onlyChild.js +3 -3
  132. package/lib/quoteAttributeValueForBrowser.js +1 -1
  133. package/lib/reactComponentExpect.js +216 -0
  134. package/lib/renderSubtreeIntoContainer.js +1 -1
  135. package/lib/setInnerHTML.js +1 -1
  136. package/lib/setTextContent.js +3 -3
  137. package/lib/shallowCompare.js +1 -1
  138. package/lib/shouldUpdateReactComponent.js +12 -8
  139. package/lib/sliceChildren.js +34 -0
  140. package/lib/traverseAllChildren.js +25 -18
  141. package/lib/update.js +13 -13
  142. package/lib/validateDOMNesting.js +6 -6
  143. package/lib/webcomponents.js +6379 -0
  144. package/package.json +4 -6
  145. package/react.js +1 -51
  146. package/dist/JSXTransformer.js +0 -17588
  147. package/lib/CSSCore.js +0 -97
  148. package/lib/EventListener.js +0 -84
  149. package/lib/ExecutionEnvironment.js +0 -38
  150. package/lib/ReactDOMClient.js +0 -90
  151. package/lib/camelize.js +0 -32
  152. package/lib/camelizeStyleName.js +0 -40
  153. package/lib/containsNode.js +0 -55
  154. package/lib/createArrayFromMixed.js +0 -85
  155. package/lib/createNodesFromMarkup.js +0 -84
  156. package/lib/emptyFunction.js +0 -38
  157. package/lib/focusNode.js +0 -26
  158. package/lib/getActiveElement.js +0 -29
  159. package/lib/getMarkupWrap.js +0 -93
  160. package/lib/getUnboundedScrollPosition.js +0 -38
  161. package/lib/hyphenate.js +0 -33
  162. package/lib/hyphenateStyleName.js +0 -39
  163. package/lib/invariant.js +0 -49
  164. package/lib/isNode.js +0 -23
  165. package/lib/joinClasses.js +0 -39
  166. package/lib/keyMirror.js +0 -48
  167. package/lib/keyOf.js +0 -35
  168. package/lib/mapObject.js +0 -51
  169. package/lib/memoizeStringOnly.js +0 -31
  170. package/lib/performanceNow.js +0 -28
  171. package/lib/shallowEqual.js +0 -48
  172. package/lib/toArray.js +0 -57
  173. package/lib/warning.js +0 -57
@@ -12,11 +12,14 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var ReactComponentEnvironment = require("./ReactComponentEnvironment");
16
- var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
15
+ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
16
+ var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
17
17
 
18
- var ReactReconciler = require("./ReactReconciler");
19
- var ReactChildReconciler = require("./ReactChildReconciler");
18
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
19
+ var ReactReconciler = require('./ReactReconciler');
20
+ var ReactChildReconciler = require('./ReactChildReconciler');
21
+
22
+ var flattenChildren = require('./flattenChildren');
20
23
 
21
24
  /**
22
25
  * Updating children of a component may trigger recursive updates. The depth is
@@ -53,14 +56,14 @@ var markupQueue = [];
53
56
  * @param {number} toIndex Destination index.
54
57
  * @private
55
58
  */
56
- function enqueueMarkup(parentID, markup, toIndex) {
59
+ function enqueueInsertMarkup(parentID, markup, toIndex) {
57
60
  // NOTE: Null values reduce hidden classes.
58
61
  updateQueue.push({
59
62
  parentID: parentID,
60
63
  parentNode: null,
61
64
  type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
62
65
  markupIndex: markupQueue.push(markup) - 1,
63
- textContent: null,
66
+ content: null,
64
67
  fromIndex: null,
65
68
  toIndex: toIndex
66
69
  });
@@ -81,7 +84,7 @@ function enqueueMove(parentID, fromIndex, toIndex) {
81
84
  parentNode: null,
82
85
  type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
83
86
  markupIndex: null,
84
- textContent: null,
87
+ content: null,
85
88
  fromIndex: fromIndex,
86
89
  toIndex: toIndex
87
90
  });
@@ -101,12 +104,32 @@ function enqueueRemove(parentID, fromIndex) {
101
104
  parentNode: null,
102
105
  type: ReactMultiChildUpdateTypes.REMOVE_NODE,
103
106
  markupIndex: null,
104
- textContent: null,
107
+ content: null,
105
108
  fromIndex: fromIndex,
106
109
  toIndex: null
107
110
  });
108
111
  }
109
112
 
113
+ /**
114
+ * Enqueues setting the markup of a node.
115
+ *
116
+ * @param {string} parentID ID of the parent component.
117
+ * @param {string} markup Markup that renders into an element.
118
+ * @private
119
+ */
120
+ function enqueueSetMarkup(parentID, markup) {
121
+ // NOTE: Null values reduce hidden classes.
122
+ updateQueue.push({
123
+ parentID: parentID,
124
+ parentNode: null,
125
+ type: ReactMultiChildUpdateTypes.SET_MARKUP,
126
+ markupIndex: null,
127
+ content: markup,
128
+ fromIndex: null,
129
+ toIndex: null
130
+ });
131
+ }
132
+
110
133
  /**
111
134
  * Enqueues setting the text content.
112
135
  *
@@ -121,7 +144,7 @@ function enqueueTextContent(parentID, textContent) {
121
144
  parentNode: null,
122
145
  type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
123
146
  markupIndex: null,
124
- textContent: textContent,
147
+ content: textContent,
125
148
  fromIndex: null,
126
149
  toIndex: null
127
150
  });
@@ -166,6 +189,37 @@ var ReactMultiChild = {
166
189
  */
167
190
  Mixin: {
168
191
 
192
+ _reconcilerInstantiateChildren: function (nestedChildren, transaction, context) {
193
+ if (process.env.NODE_ENV !== 'production') {
194
+ if (this._currentElement) {
195
+ try {
196
+ ReactCurrentOwner.current = this._currentElement._owner;
197
+ return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
198
+ } finally {
199
+ ReactCurrentOwner.current = null;
200
+ }
201
+ }
202
+ }
203
+ return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
204
+ },
205
+
206
+ _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, transaction, context) {
207
+ var nextChildren;
208
+ if (process.env.NODE_ENV !== 'production') {
209
+ if (this._currentElement) {
210
+ try {
211
+ ReactCurrentOwner.current = this._currentElement._owner;
212
+ nextChildren = flattenChildren(nextNestedChildrenElements);
213
+ } finally {
214
+ ReactCurrentOwner.current = null;
215
+ }
216
+ return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
217
+ }
218
+ }
219
+ nextChildren = flattenChildren(nextNestedChildrenElements);
220
+ return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
221
+ },
222
+
169
223
  /**
170
224
  * Generates a "mount image" for each of the supplied children. In the case
171
225
  * of `ReactDOMComponent`, a mount image is a string of markup.
@@ -175,7 +229,7 @@ var ReactMultiChild = {
175
229
  * @internal
176
230
  */
177
231
  mountChildren: function (nestedChildren, transaction, context) {
178
- var children = ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
232
+ var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context);
179
233
  this._renderedChildren = children;
180
234
  var mountImages = [];
181
235
  var index = 0;
@@ -185,9 +239,8 @@ var ReactMultiChild = {
185
239
  // Inlined for performance, see `ReactInstanceHandles.createReactID`.
186
240
  var rootID = this._rootNodeID + name;
187
241
  var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
188
- child._mountIndex = index;
242
+ child._mountIndex = index++;
189
243
  mountImages.push(mountImage);
190
- index++;
191
244
  }
192
245
  }
193
246
  return mountImages;
@@ -209,7 +262,7 @@ var ReactMultiChild = {
209
262
  // TODO: The setTextContent operation should be enough
210
263
  for (var name in prevChildren) {
211
264
  if (prevChildren.hasOwnProperty(name)) {
212
- this._unmountChildByName(prevChildren[name], name);
265
+ this._unmountChild(prevChildren[name]);
213
266
  }
214
267
  }
215
268
  // Set new text content.
@@ -227,18 +280,50 @@ var ReactMultiChild = {
227
280
  }
228
281
  },
229
282
 
283
+ /**
284
+ * Replaces any rendered children with a markup string.
285
+ *
286
+ * @param {string} nextMarkup String of markup.
287
+ * @internal
288
+ */
289
+ updateMarkup: function (nextMarkup) {
290
+ updateDepth++;
291
+ var errorThrown = true;
292
+ try {
293
+ var prevChildren = this._renderedChildren;
294
+ // Remove any rendered children.
295
+ ReactChildReconciler.unmountChildren(prevChildren);
296
+ for (var name in prevChildren) {
297
+ if (prevChildren.hasOwnProperty(name)) {
298
+ this._unmountChildByName(prevChildren[name], name);
299
+ }
300
+ }
301
+ this.setMarkup(nextMarkup);
302
+ errorThrown = false;
303
+ } finally {
304
+ updateDepth--;
305
+ if (!updateDepth) {
306
+ if (errorThrown) {
307
+ clearQueue();
308
+ } else {
309
+ processQueue();
310
+ }
311
+ }
312
+ }
313
+ },
314
+
230
315
  /**
231
316
  * Updates the rendered children with new children.
232
317
  *
233
- * @param {?object} nextNestedChildren Nested child maps.
318
+ * @param {?object} nextNestedChildrenElements Nested child element maps.
234
319
  * @param {ReactReconcileTransaction} transaction
235
320
  * @internal
236
321
  */
237
- updateChildren: function (nextNestedChildren, transaction, context) {
322
+ updateChildren: function (nextNestedChildrenElements, transaction, context) {
238
323
  updateDepth++;
239
324
  var errorThrown = true;
240
325
  try {
241
- this._updateChildren(nextNestedChildren, transaction, context);
326
+ this._updateChildren(nextNestedChildrenElements, transaction, context);
242
327
  errorThrown = false;
243
328
  } finally {
244
329
  updateDepth--;
@@ -256,14 +341,14 @@ var ReactMultiChild = {
256
341
  * Improve performance by isolating this hot code path from the try/catch
257
342
  * block in `updateChildren`.
258
343
  *
259
- * @param {?object} nextNestedChildren Nested child maps.
344
+ * @param {?object} nextNestedChildrenElements Nested child element maps.
260
345
  * @param {ReactReconcileTransaction} transaction
261
346
  * @final
262
347
  * @protected
263
348
  */
264
- _updateChildren: function (nextNestedChildren, transaction, context) {
349
+ _updateChildren: function (nextNestedChildrenElements, transaction, context) {
265
350
  var prevChildren = this._renderedChildren;
266
- var nextChildren = ReactChildReconciler.updateChildren(prevChildren, nextNestedChildren, transaction, context);
351
+ var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, transaction, context);
267
352
  this._renderedChildren = nextChildren;
268
353
  if (!nextChildren && !prevChildren) {
269
354
  return;
@@ -287,7 +372,7 @@ var ReactMultiChild = {
287
372
  if (prevChild) {
288
373
  // Update `lastIndex` before `_mountIndex` gets unset by unmounting.
289
374
  lastIndex = Math.max(prevChild._mountIndex, lastIndex);
290
- this._unmountChildByName(prevChild, name);
375
+ this._unmountChild(prevChild);
291
376
  }
292
377
  // The child must be instantiated before it's mounted.
293
378
  this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context);
@@ -297,7 +382,7 @@ var ReactMultiChild = {
297
382
  // Remove children that are no longer present.
298
383
  for (name in prevChildren) {
299
384
  if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
300
- this._unmountChildByName(prevChildren[name], name);
385
+ this._unmountChild(prevChildren[name]);
301
386
  }
302
387
  }
303
388
  },
@@ -339,7 +424,7 @@ var ReactMultiChild = {
339
424
  * @protected
340
425
  */
341
426
  createChild: function (child, mountImage) {
342
- enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
427
+ enqueueInsertMarkup(this._rootNodeID, mountImage, child._mountIndex);
343
428
  },
344
429
 
345
430
  /**
@@ -362,6 +447,16 @@ var ReactMultiChild = {
362
447
  enqueueTextContent(this._rootNodeID, textContent);
363
448
  },
364
449
 
450
+ /**
451
+ * Sets this markup string.
452
+ *
453
+ * @param {string} markup Markup to set.
454
+ * @protected
455
+ */
456
+ setMarkup: function (markup) {
457
+ enqueueSetMarkup(this._rootNodeID, markup);
458
+ },
459
+
365
460
  /**
366
461
  * Mounts a child with the supplied name.
367
462
  *
@@ -382,15 +477,14 @@ var ReactMultiChild = {
382
477
  },
383
478
 
384
479
  /**
385
- * Unmounts a rendered child by name.
480
+ * Unmounts a rendered child.
386
481
  *
387
482
  * NOTE: This is part of `updateChildren` and is here for readability.
388
483
  *
389
484
  * @param {ReactComponent} child Component to unmount.
390
- * @param {string} name Name of the child in `this._renderedChildren`.
391
485
  * @private
392
486
  */
393
- _unmountChildByName: function (child, name) {
487
+ _unmountChild: function (child) {
394
488
  this.removeChild(child);
395
489
  child._mountIndex = null;
396
490
  }
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var keyMirror = require("./keyMirror");
14
+ var keyMirror = require('fbjs/lib/keyMirror');
15
15
 
16
16
  /**
17
17
  * When a component's children are updated, a series of update configuration
@@ -25,6 +25,7 @@ var ReactMultiChildUpdateTypes = keyMirror({
25
25
  INSERT_MARKUP: null,
26
26
  MOVE_EXISTING: null,
27
27
  REMOVE_NODE: null,
28
+ SET_MARKUP: null,
28
29
  TEXT_CONTENT: null
29
30
  });
30
31
 
@@ -11,8 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var assign = require("./Object.assign");
15
- var invariant = require("./invariant");
14
+ var assign = require('./Object.assign');
15
+ var invariant = require('fbjs/lib/invariant');
16
16
 
17
17
  var autoGenerateWrapperClass = null;
18
18
  var genericComponentClass = null;
@@ -63,7 +63,7 @@ function getComponentClassForElement(element) {
63
63
  * @return {function} The internal class constructor function.
64
64
  */
65
65
  function createInternalComponent(element) {
66
- !genericComponentClass ? 'production' !== process.env.NODE_ENV ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
66
+ !genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
67
67
  return new genericComponentClass(element.type, element.props);
68
68
  }
69
69
 
@@ -11,11 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var warning = require("./warning");
14
+ var warning = require('fbjs/lib/warning');
15
15
 
16
16
  function warnTDZ(publicInstance, callerName) {
17
- if ('production' !== process.env.NODE_ENV) {
18
- 'production' !== process.env.NODE_ENV ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined;
17
+ if (process.env.NODE_ENV !== 'production') {
18
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined;
19
19
  }
20
20
  }
21
21
 
package/lib/ReactOwner.js CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var invariant = require("./invariant");
14
+ var invariant = require('fbjs/lib/invariant');
15
15
 
16
16
  /**
17
17
  * ReactOwners are capable of storing references to owned components.
@@ -64,7 +64,7 @@ var ReactOwner = {
64
64
  * @internal
65
65
  */
66
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;
67
+ !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
68
68
  owner.attachRef(ref, component);
69
69
  },
70
70
 
@@ -78,7 +78,7 @@ var ReactOwner = {
78
78
  * @internal
79
79
  */
80
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;
81
+ !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
82
82
  // Check that `component` is still the current ref because we do not want to
83
83
  // detach the ref if another component stole it.
84
84
  if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
package/lib/ReactPerf.js CHANGED
@@ -35,7 +35,7 @@ var ReactPerf = {
35
35
  * @param {object<string>} methodNames
36
36
  */
37
37
  measureMethods: function (object, objectName, methodNames) {
38
- if ('production' !== process.env.NODE_ENV) {
38
+ if (process.env.NODE_ENV !== 'production') {
39
39
  for (var key in methodNames) {
40
40
  if (!methodNames.hasOwnProperty(key)) {
41
41
  continue;
@@ -54,7 +54,7 @@ var ReactPerf = {
54
54
  * @return {function}
55
55
  */
56
56
  measure: function (objName, fnName, func) {
57
- if ('production' !== process.env.NODE_ENV) {
57
+ if (process.env.NODE_ENV !== 'production') {
58
58
  var measuredFunc = null;
59
59
  var wrapper = function () {
60
60
  if (ReactPerf.enableMeasure) {
@@ -11,9 +11,9 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var assign = require("./Object.assign");
15
- var emptyFunction = require("./emptyFunction");
16
- var joinClasses = require("./joinClasses");
14
+ var assign = require('./Object.assign');
15
+ var emptyFunction = require('fbjs/lib/emptyFunction');
16
+ var joinClasses = require('fbjs/lib/joinClasses');
17
17
 
18
18
  /**
19
19
  * Creates a transfer strategy that will merge prop values using the supplied
@@ -13,7 +13,7 @@
13
13
 
14
14
  var ReactPropTypeLocationNames = {};
15
15
 
16
- if ('production' !== process.env.NODE_ENV) {
16
+ if (process.env.NODE_ENV !== 'production') {
17
17
  ReactPropTypeLocationNames = {
18
18
  prop: 'prop',
19
19
  context: 'context',
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var keyMirror = require("./keyMirror");
14
+ var keyMirror = require('fbjs/lib/keyMirror');
15
15
 
16
16
  var ReactPropTypeLocations = keyMirror({
17
17
  prop: null,
@@ -11,11 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactElement = require("./ReactElement");
15
- var ReactFragment = require("./ReactFragment");
16
- var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
14
+ var ReactElement = require('./ReactElement');
15
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
17
16
 
18
- var emptyFunction = require("./emptyFunction");
17
+ var emptyFunction = require('fbjs/lib/emptyFunction');
18
+ var getIteratorFn = require('./getIteratorFn');
19
19
 
20
20
  /**
21
21
  * Collection of methods that allow declaration and validation of props that are
@@ -163,7 +163,8 @@ function createInstanceTypeChecker(expectedClass) {
163
163
  if (!(props[propName] instanceof expectedClass)) {
164
164
  var locationName = ReactPropTypeLocationNames[location];
165
165
  var expectedClassName = expectedClass.name || ANONYMOUS;
166
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
166
+ var actualClassName = getClassName(props[propName]);
167
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
167
168
  }
168
169
  return null;
169
170
  }
@@ -283,12 +284,32 @@ function isNode(propValue) {
283
284
  if (propValue === null || ReactElement.isValidElement(propValue)) {
284
285
  return true;
285
286
  }
286
- propValue = ReactFragment.extractIfFragment(propValue);
287
- for (var k in propValue) {
288
- if (!isNode(propValue[k])) {
289
- return false;
287
+
288
+ var iteratorFn = getIteratorFn(propValue);
289
+ if (iteratorFn) {
290
+ var iterator = iteratorFn.call(propValue);
291
+ var step;
292
+ if (iteratorFn !== propValue.entries) {
293
+ while (!(step = iterator.next()).done) {
294
+ if (!isNode(step.value)) {
295
+ return false;
296
+ }
297
+ }
298
+ } else {
299
+ // Iterator will provide entry [k,v] tuples rather than values.
300
+ while (!(step = iterator.next()).done) {
301
+ var entry = step.value;
302
+ if (entry) {
303
+ if (!isNode(entry[1])) {
304
+ return false;
305
+ }
306
+ }
307
+ }
290
308
  }
309
+ } else {
310
+ return false;
291
311
  }
312
+
292
313
  return true;
293
314
  default:
294
315
  return false;
@@ -324,4 +345,12 @@ function getPreciseType(propValue) {
324
345
  return propType;
325
346
  }
326
347
 
348
+ // Returns class name of the object, if any.
349
+ function getClassName(propValue) {
350
+ if (!propValue.constructor || !propValue.constructor.name) {
351
+ return '<<anonymous>>';
352
+ }
353
+ return propValue.constructor.name;
354
+ }
355
+
327
356
  module.exports = ReactPropTypes;