react 0.13.0-beta.1 → 0.13.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 (181) hide show
  1. package/dist/JSXTransformer.js +1919 -1295
  2. package/dist/react-with-addons.js +1690 -1090
  3. package/dist/react-with-addons.min.js +7 -6
  4. package/dist/react.js +1574 -1010
  5. package/dist/react.min.js +6 -6
  6. package/lib/AutoFocusMixin.js +1 -1
  7. package/lib/BeforeInputEventPlugin.js +1 -5
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +3 -1
  10. package/lib/CSSPropertyOperations.js +1 -1
  11. package/lib/CallbackQueue.js +1 -1
  12. package/lib/ChangeEventPlugin.js +1 -1
  13. package/lib/ClientReactRootIndex.js +1 -1
  14. package/lib/DOMChildrenOperations.js +4 -43
  15. package/lib/DOMProperty.js +1 -1
  16. package/lib/DOMPropertyOperations.js +7 -14
  17. package/lib/Danger.js +1 -1
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +1 -1
  20. package/lib/EventConstants.js +1 -1
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +1 -1
  23. package/lib/EventPluginRegistry.js +1 -1
  24. package/lib/EventPluginUtils.js +3 -3
  25. package/lib/EventPropagators.js +1 -1
  26. package/lib/ExecutionEnvironment.js +1 -1
  27. package/lib/FallbackCompositionState.js +1 -1
  28. package/lib/HTMLDOMPropertyConfig.js +12 -5
  29. package/lib/LinkedStateMixin.js +1 -1
  30. package/lib/LinkedValueUtils.js +1 -1
  31. package/lib/LocalEventTrapMixin.js +1 -1
  32. package/lib/MobileSafariClickEventPlugin.js +1 -1
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +1 -1
  35. package/lib/React.js +7 -9
  36. package/lib/ReactBrowserComponentMixin.js +1 -1
  37. package/lib/ReactBrowserEventEmitter.js +2 -2
  38. package/lib/ReactCSSTransitionGroup.js +1 -1
  39. package/lib/ReactCSSTransitionGroupChild.js +8 -5
  40. package/lib/ReactChildReconciler.js +1 -1
  41. package/lib/ReactChildren.js +3 -2
  42. package/lib/ReactClass.js +49 -23
  43. package/lib/ReactComponent.js +35 -19
  44. package/lib/ReactComponentBrowserEnvironment.js +1 -1
  45. package/lib/ReactComponentEnvironment.js +1 -1
  46. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  47. package/lib/ReactCompositeComponent.js +89 -40
  48. package/lib/ReactContext.js +13 -3
  49. package/lib/ReactCurrentOwner.js +1 -1
  50. package/lib/ReactDOM.js +1 -1
  51. package/lib/ReactDOMButton.js +1 -1
  52. package/lib/ReactDOMComponent.js +19 -19
  53. package/lib/ReactDOMForm.js +1 -1
  54. package/lib/ReactDOMIDOperations.js +3 -3
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +1 -1
  57. package/lib/ReactDOMInput.js +1 -1
  58. package/lib/ReactDOMOption.js +1 -1
  59. package/lib/ReactDOMSelect.js +1 -1
  60. package/lib/ReactDOMSelection.js +1 -1
  61. package/lib/ReactDOMTextComponent.js +3 -5
  62. package/lib/ReactDOMTextarea.js +1 -1
  63. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  64. package/lib/ReactDefaultInjection.js +25 -1
  65. package/lib/ReactDefaultPerf.js +5 -10
  66. package/lib/ReactDefaultPerfAnalysis.js +1 -1
  67. package/lib/ReactElement.js +56 -2
  68. package/lib/ReactElementValidator.js +122 -79
  69. package/lib/ReactEmptyComponent.js +5 -5
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +1 -1
  72. package/lib/ReactEventListener.js +1 -1
  73. package/lib/ReactFragment.js +181 -0
  74. package/lib/ReactInjection.js +1 -1
  75. package/lib/ReactInputSelection.js +1 -1
  76. package/lib/ReactInstanceHandles.js +1 -1
  77. package/lib/ReactInstanceMap.js +1 -1
  78. package/lib/ReactLifeCycle.js +1 -1
  79. package/lib/ReactLink.js +1 -1
  80. package/lib/ReactMarkupChecksum.js +1 -1
  81. package/lib/ReactMount.js +32 -10
  82. package/lib/ReactMultiChild.js +1 -1
  83. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  84. package/lib/ReactNativeComponent.js +7 -20
  85. package/lib/ReactOwner.js +1 -1
  86. package/lib/ReactPerf.js +1 -1
  87. package/lib/ReactPropTransferer.js +1 -1
  88. package/lib/ReactPropTypeLocationNames.js +1 -1
  89. package/lib/ReactPropTypeLocations.js +1 -1
  90. package/lib/ReactPropTypes.js +7 -4
  91. package/lib/ReactPutListenerQueue.js +1 -1
  92. package/lib/ReactReconcileTransaction.js +1 -1
  93. package/lib/ReactReconciler.js +15 -2
  94. package/lib/ReactRef.js +2 -3
  95. package/lib/ReactRootIndex.js +1 -1
  96. package/lib/ReactServerRendering.js +1 -1
  97. package/lib/ReactServerRenderingTransaction.js +1 -1
  98. package/lib/ReactStateSetters.js +1 -1
  99. package/lib/ReactTestUtils.js +19 -7
  100. package/lib/ReactTransitionChildMapping.js +7 -3
  101. package/lib/ReactTransitionEvents.js +1 -1
  102. package/lib/ReactTransitionGroup.js +5 -5
  103. package/lib/ReactUpdateQueue.js +63 -32
  104. package/lib/ReactUpdates.js +7 -2
  105. package/lib/ReactWithAddons.js +3 -1
  106. package/lib/SVGDOMPropertyConfig.js +1 -1
  107. package/lib/SelectEventPlugin.js +1 -1
  108. package/lib/ServerReactRootIndex.js +1 -1
  109. package/lib/SimpleEventPlugin.js +3 -3
  110. package/lib/SyntheticClipboardEvent.js +1 -1
  111. package/lib/SyntheticCompositionEvent.js +1 -1
  112. package/lib/SyntheticDragEvent.js +1 -1
  113. package/lib/SyntheticEvent.js +1 -1
  114. package/lib/SyntheticFocusEvent.js +1 -1
  115. package/lib/SyntheticInputEvent.js +1 -1
  116. package/lib/SyntheticKeyboardEvent.js +1 -1
  117. package/lib/SyntheticMouseEvent.js +1 -1
  118. package/lib/SyntheticTouchEvent.js +1 -1
  119. package/lib/SyntheticUIEvent.js +1 -1
  120. package/lib/SyntheticWheelEvent.js +1 -1
  121. package/lib/Transaction.js +2 -2
  122. package/lib/ViewportMetrics.js +1 -1
  123. package/lib/accumulateInto.js +1 -1
  124. package/lib/adler32.js +1 -1
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +4 -4
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +1 -1
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +16 -1
  133. package/lib/dangerousStyleValue.js +1 -1
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +4 -5
  137. package/lib/findDOMNode.js +19 -1
  138. package/lib/flattenChildren.js +1 -1
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +1 -1
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +1 -1
  143. package/lib/getEventKey.js +1 -1
  144. package/lib/getEventModifierState.js +1 -1
  145. package/lib/getEventTarget.js +1 -1
  146. package/lib/getIteratorFn.js +1 -1
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +1 -1
  149. package/lib/getReactRootElementInContainer.js +1 -1
  150. package/lib/getTextContentAccessor.js +1 -1
  151. package/lib/getUnboundedScrollPosition.js +1 -1
  152. package/lib/hyphenate.js +1 -1
  153. package/lib/hyphenateStyleName.js +1 -1
  154. package/lib/instantiateReactComponent.js +6 -1
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +1 -1
  157. package/lib/isNode.js +1 -1
  158. package/lib/isTextInputElement.js +1 -1
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +1 -1
  161. package/lib/keyMirror.js +1 -1
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +1 -1
  165. package/lib/onlyChild.js +1 -1
  166. package/lib/performance.js +1 -1
  167. package/lib/performanceNow.js +1 -1
  168. package/lib/quoteAttributeValueForBrowser.js +26 -0
  169. package/lib/setInnerHTML.js +1 -1
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +1 -1
  172. package/lib/shouldUpdateReactComponent.js +32 -10
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +18 -4
  175. package/lib/update.js +1 -1
  176. package/lib/warning.js +9 -2
  177. package/package.json +1 -1
  178. package/lib/copyProperties.js +0 -56
  179. package/lib/merge.js +0 -34
  180. package/lib/mergeInto.js +0 -24
  181. package/lib/monitorCodeUse.js +0 -30
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014, Facebook, Inc.
2
+ * Copyright 2014-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -19,13 +19,13 @@
19
19
  'use strict';
20
20
 
21
21
  var ReactElement = require("./ReactElement");
22
+ var ReactFragment = require("./ReactFragment");
22
23
  var ReactPropTypeLocations = require("./ReactPropTypeLocations");
23
24
  var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
24
25
  var ReactCurrentOwner = require("./ReactCurrentOwner");
25
26
  var ReactNativeComponent = require("./ReactNativeComponent");
26
27
 
27
28
  var getIteratorFn = require("./getIteratorFn");
28
- var monitorCodeUse = require("./monitorCodeUse");
29
29
  var invariant = require("./invariant");
30
30
  var warning = require("./warning");
31
31
 
@@ -44,11 +44,7 @@ function getDeclarationErrorAddendum() {
44
44
  * object keys are not valid. This allows us to keep track of children between
45
45
  * updates.
46
46
  */
47
- var ownerHasKeyUseWarning = {
48
- 'react_key_warning': {},
49
- 'react_numeric_key_warning': {}
50
- };
51
- var ownerHasMonitoredObjectMap = {};
47
+ var ownerHasKeyUseWarning = {};
52
48
 
53
49
  var loggedTypeFailures = {};
54
50
 
@@ -102,7 +98,6 @@ function validateExplicitKey(element, parentType) {
102
98
  element._store.validated = true;
103
99
 
104
100
  warnAndMonitorForKeyUse(
105
- 'react_key_warning',
106
101
  'Each child in an array or iterator should have a unique "key" prop.',
107
102
  element,
108
103
  parentType
@@ -123,7 +118,6 @@ function validatePropertyKey(name, element, parentType) {
123
118
  return;
124
119
  }
125
120
  warnAndMonitorForKeyUse(
126
- 'react_numeric_key_warning',
127
121
  'Child objects should have non-numeric keys so ordering is preserved.',
128
122
  element,
129
123
  parentType
@@ -134,60 +128,48 @@ function validatePropertyKey(name, element, parentType) {
134
128
  * Shared warning and monitoring code for the key warnings.
135
129
  *
136
130
  * @internal
137
- * @param {string} warningID The id used when logging.
138
131
  * @param {string} message The base warning that gets output.
139
132
  * @param {ReactElement} element Component that requires a key.
140
133
  * @param {*} parentType element's parent's type.
141
134
  */
142
- function warnAndMonitorForKeyUse(warningID, message, element, parentType) {
135
+ function warnAndMonitorForKeyUse(message, element, parentType) {
143
136
  var ownerName = getCurrentOwnerDisplayName();
144
- var parentName = parentType.displayName || parentType.name;
137
+ var parentName = typeof parentType === 'string' ?
138
+ parentType : parentType.displayName || parentType.name;
145
139
 
146
140
  var useName = ownerName || parentName;
147
- var memoizer = ownerHasKeyUseWarning[warningID];
141
+ var memoizer = ownerHasKeyUseWarning[message] || (
142
+ (ownerHasKeyUseWarning[message] = {})
143
+ );
148
144
  if (memoizer.hasOwnProperty(useName)) {
149
145
  return;
150
146
  }
151
147
  memoizer[useName] = true;
152
148
 
153
- message += ownerName ?
154
- (" Check the render method of " + ownerName + ".") :
155
- (" Check the React.render call using <" + parentName + ">.");
149
+ var parentOrOwnerAddendum =
150
+ ownerName ? (" Check the render method of " + ownerName + ".") :
151
+ parentName ? (" Check the React.render call using <" + parentName + ">.") :
152
+ '';
156
153
 
157
154
  // Usually the current owner is the offender, but if it accepts children as a
158
155
  // property, it may be the creator of the child that's responsible for
159
156
  // assigning it a key.
160
- var childOwnerName = null;
157
+ var childOwnerAddendum = '';
161
158
  if (element &&
162
159
  element._owner &&
163
160
  element._owner !== ReactCurrentOwner.current) {
164
161
  // Name of the component that originally created this child.
165
- childOwnerName = getName(element._owner);
162
+ var childOwnerName = getName(element._owner);
166
163
 
167
- message += (" It was passed a child from " + childOwnerName + ".");
164
+ childOwnerAddendum = (" It was passed a child from " + childOwnerName + ".");
168
165
  }
169
166
 
170
- message += ' See http://fb.me/react-warning-keys for more information.';
171
- monitorCodeUse(warningID, {
172
- component: useName,
173
- componentOwner: childOwnerName
174
- });
175
- console.warn(message);
176
- }
177
-
178
- /**
179
- * Log that we're using an object map. We're considering deprecating this
180
- * feature and replace it with proper Map and ImmutableMap data structures.
181
- *
182
- * @internal
183
- */
184
- function monitorUseOfObjectMap() {
185
- var currentName = getCurrentOwnerDisplayName() || '';
186
- if (ownerHasMonitoredObjectMap.hasOwnProperty(currentName)) {
187
- return;
188
- }
189
- ownerHasMonitoredObjectMap[currentName] = true;
190
- monitorCodeUse('react_object_map_children');
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);
191
173
  }
192
174
 
193
175
  /**
@@ -213,19 +195,21 @@ function validateChildKeys(node, parentType) {
213
195
  } else if (node) {
214
196
  var iteratorFn = getIteratorFn(node);
215
197
  // Entry iterators provide implicit keys.
216
- if (iteratorFn && iteratorFn !== node.entries) {
217
- var iterator = iteratorFn.call(node);
218
- var step;
219
- while (!(step = iterator.next()).done) {
220
- if (ReactElement.isValidElement(step.value)) {
221
- validateExplicitKey(step.value, parentType);
198
+ if (iteratorFn) {
199
+ if (iteratorFn !== node.entries) {
200
+ var iterator = iteratorFn.call(node);
201
+ var step;
202
+ while (!(step = iterator.next()).done) {
203
+ if (ReactElement.isValidElement(step.value)) {
204
+ validateExplicitKey(step.value, parentType);
205
+ }
222
206
  }
223
207
  }
224
208
  } else if (typeof node === 'object') {
225
- monitorUseOfObjectMap();
226
- for (var key in node) {
227
- if (node.hasOwnProperty(key)) {
228
- validatePropertyKey(key, node[key], parentType);
209
+ var fragment = ReactFragment.extractIfFragment(node);
210
+ for (var key in fragment) {
211
+ if (fragment.hasOwnProperty(key)) {
212
+ validatePropertyKey(key, fragment[key], parentType);
229
213
  }
230
214
  }
231
215
  }
@@ -269,7 +253,7 @@ function checkPropTypes(componentName, propTypes, props, location) {
269
253
  loggedTypeFailures[error.message] = true;
270
254
 
271
255
  var addendum = getDeclarationErrorAddendum(this);
272
- ("production" !== process.env.NODE_ENV ? warning(false, error.message + addendum) : null);
256
+ ("production" !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null);
273
257
  }
274
258
  }
275
259
  }
@@ -315,6 +299,19 @@ function warnForPropsMutation(propName, element) {
315
299
  ) : null);
316
300
  }
317
301
 
302
+ // Inline Object.is polyfill
303
+ function is(a, b) {
304
+ if (a !== a) {
305
+ // NaN
306
+ return b !== b;
307
+ }
308
+ if (a === 0 && b === 0) {
309
+ // +-0
310
+ return 1 / a === 1 / b;
311
+ }
312
+ return a === b;
313
+ }
314
+
318
315
  /**
319
316
  * Given an element, check if its props have been mutated since element
320
317
  * creation (or the last call to this function). In particular, check if any
@@ -336,7 +333,7 @@ function checkAndWarnForMutatedProps(element) {
336
333
  for (var propName in props) {
337
334
  if (props.hasOwnProperty(propName)) {
338
335
  if (!originalProps.hasOwnProperty(propName) ||
339
- originalProps[propName] !== props[propName]) {
336
+ !is(originalProps[propName], props[propName])) {
340
337
  warnForPropsMutation(propName, element);
341
338
 
342
339
  // Copy over the new value so that the two props objects match again
@@ -346,6 +343,42 @@ function checkAndWarnForMutatedProps(element) {
346
343
  }
347
344
  }
348
345
 
346
+ /**
347
+ * Given an element, validate that its props follow the propTypes definition,
348
+ * provided by the type.
349
+ *
350
+ * @param {ReactElement} element
351
+ */
352
+ function validatePropTypes(element) {
353
+ if (element.type == null) {
354
+ // This has already warned. Don't throw.
355
+ return;
356
+ }
357
+ // Extract the component class from the element. Converts string types
358
+ // to a composite class which may have propTypes.
359
+ // TODO: Validating a string's propTypes is not decoupled from the
360
+ // rendering target which is problematic.
361
+ var componentClass = ReactNativeComponent.getComponentClassForElement(
362
+ element
363
+ );
364
+ var name = componentClass.displayName || componentClass.name;
365
+ if (componentClass.propTypes) {
366
+ checkPropTypes(
367
+ name,
368
+ componentClass.propTypes,
369
+ element.props,
370
+ ReactPropTypeLocations.prop
371
+ );
372
+ }
373
+ 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);
379
+ }
380
+ }
381
+
349
382
  var ReactElementValidator = {
350
383
 
351
384
  checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
@@ -372,33 +405,7 @@ var ReactElementValidator = {
372
405
  validateChildKeys(arguments[i], type);
373
406
  }
374
407
 
375
- if (type) {
376
- // Extract the component class from the element. Converts string types
377
- // to a composite class which may have propTypes.
378
- // TODO: Validating a string's propTypes is not decoupled from the
379
- // rendering target which is problematic.
380
- var componentClass = ReactNativeComponent.getComponentClassForElement(
381
- element
382
- );
383
- var name = componentClass.displayName || componentClass.name;
384
- if ("production" !== process.env.NODE_ENV) {
385
- if (componentClass.propTypes) {
386
- checkPropTypes(
387
- name,
388
- componentClass.propTypes,
389
- element.props,
390
- ReactPropTypeLocations.prop
391
- );
392
- }
393
- }
394
- if (typeof componentClass.getDefaultProps === 'function') {
395
- ("production" !== process.env.NODE_ENV ? warning(
396
- componentClass.getDefaultProps.isReactClassApproved,
397
- 'getDefaultProps is only used on classic React.createClass ' +
398
- 'definitions. Use a static property named `defaultProps` instead.'
399
- ) : null);
400
- }
401
- }
408
+ validatePropTypes(element);
402
409
 
403
410
  return element;
404
411
  },
@@ -410,7 +417,43 @@ var ReactElementValidator = {
410
417
  );
411
418
  // Legacy hook TODO: Warn if this is accessed
412
419
  validatedFactory.type = type;
420
+
421
+ if ("production" !== process.env.NODE_ENV) {
422
+ 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
+ }
439
+ }
440
+ );
441
+ } catch (x) {
442
+ // IE will fail on defineProperty (es5-shim/sham too)
443
+ }
444
+ }
445
+
446
+
413
447
  return validatedFactory;
448
+ },
449
+
450
+ cloneElement: function(element, props, children) {
451
+ var newElement = ReactElement.cloneElement.apply(this, arguments);
452
+ for (var i = 2; i < arguments.length; i++) {
453
+ validateChildKeys(arguments[i], newElement.type);
454
+ }
455
+ validatePropTypes(newElement);
456
+ return newElement;
414
457
  }
415
458
 
416
459
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014, Facebook, Inc.
2
+ * Copyright 2014-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -19,7 +19,7 @@ var invariant = require("./invariant");
19
19
  var component;
20
20
  // This registry keeps track of the React IDs of the components that rendered to
21
21
  // `null` (in reality a placeholder such as `noscript`)
22
- var nullComponentIdsRegistry = {};
22
+ var nullComponentIDsRegistry = {};
23
23
 
24
24
  var ReactEmptyComponentInjection = {
25
25
  injectEmptyComponent: function(emptyComponent) {
@@ -63,7 +63,7 @@ var emptyElement = ReactElement.createElement(ReactEmptyComponentType);
63
63
  * @param {string} id Component's `_rootNodeID`.
64
64
  */
65
65
  function registerNullComponentID(id) {
66
- nullComponentIdsRegistry[id] = true;
66
+ nullComponentIDsRegistry[id] = true;
67
67
  }
68
68
 
69
69
  /**
@@ -71,7 +71,7 @@ function registerNullComponentID(id) {
71
71
  * @param {string} id Component's `_rootNodeID`.
72
72
  */
73
73
  function deregisterNullComponentID(id) {
74
- delete nullComponentIdsRegistry[id];
74
+ delete nullComponentIDsRegistry[id];
75
75
  }
76
76
 
77
77
  /**
@@ -79,7 +79,7 @@ function deregisterNullComponentID(id) {
79
79
  * @return {boolean} True if the component is rendered to null.
80
80
  */
81
81
  function isNullComponentID(id) {
82
- return !!nullComponentIdsRegistry[id];
82
+ return !!nullComponentIDsRegistry[id];
83
83
  }
84
84
 
85
85
  var ReactEmptyComponent = {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Copyright 2015, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule ReactFragment
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactElement = require("./ReactElement");
15
+
16
+ var warning = require("./warning");
17
+
18
+ /**
19
+ * We used to allow keyed objects to serve as a collection of ReactElements,
20
+ * or nested sets. This allowed us a way to explicitly key a set a fragment of
21
+ * components. This is now being replaced with an opaque data structure.
22
+ * The upgrade path is to call React.addons.createFragment({ key: value }) to
23
+ * create a keyed fragment. The resulting data structure is opaque, for now.
24
+ */
25
+
26
+ if ("production" !== process.env.NODE_ENV) {
27
+ var fragmentKey = '_reactFragment';
28
+ var didWarnKey = '_reactDidWarn';
29
+ var canWarnForReactFragment = false;
30
+
31
+ try {
32
+ // Feature test. Don't even try to issue this warning if we can't use
33
+ // enumerable: false.
34
+
35
+ var dummy = function() {
36
+ return 1;
37
+ };
38
+
39
+ Object.defineProperty(
40
+ {},
41
+ fragmentKey,
42
+ {enumerable: false, value: true}
43
+ );
44
+
45
+ Object.defineProperty(
46
+ {},
47
+ 'key',
48
+ {enumerable: true, get: dummy}
49
+ );
50
+
51
+ canWarnForReactFragment = true;
52
+ } catch (x) { }
53
+
54
+ var proxyPropertyAccessWithWarning = function(obj, key) {
55
+ Object.defineProperty(obj, key, {
56
+ enumerable: true,
57
+ get: function() {
58
+ ("production" !== process.env.NODE_ENV ? warning(
59
+ this[didWarnKey],
60
+ 'A ReactFragment is an opaque type. Accessing any of its ' +
61
+ 'properties is deprecated. Pass it to one of the React.Children ' +
62
+ 'helpers.'
63
+ ) : null);
64
+ this[didWarnKey] = true;
65
+ return this[fragmentKey][key];
66
+ },
67
+ set: function(value) {
68
+ ("production" !== process.env.NODE_ENV ? warning(
69
+ this[didWarnKey],
70
+ 'A ReactFragment is an immutable opaque type. Mutating its ' +
71
+ 'properties is deprecated.'
72
+ ) : null);
73
+ this[didWarnKey] = true;
74
+ this[fragmentKey][key] = value;
75
+ }
76
+ });
77
+ };
78
+
79
+ var issuedWarnings = {};
80
+
81
+ var didWarnForFragment = function(fragment) {
82
+ // We use the keys and the type of the value as a heuristic to dedupe the
83
+ // warning to avoid spamming too much.
84
+ var fragmentCacheKey = '';
85
+ for (var key in fragment) {
86
+ fragmentCacheKey += key + ':' + (typeof fragment[key]) + ',';
87
+ }
88
+ var alreadyWarnedOnce = !!issuedWarnings[fragmentCacheKey];
89
+ issuedWarnings[fragmentCacheKey] = true;
90
+ return alreadyWarnedOnce;
91
+ };
92
+ }
93
+
94
+ var ReactFragment = {
95
+ // Wrap a keyed object in an opaque proxy that warns you if you access any
96
+ // of its properties.
97
+ create: function(object) {
98
+ if ("production" !== process.env.NODE_ENV) {
99
+ if (typeof object !== 'object' || !object || Array.isArray(object)) {
100
+ ("production" !== process.env.NODE_ENV ? warning(
101
+ false,
102
+ 'React.addons.createFragment only accepts a single object.',
103
+ object
104
+ ) : null);
105
+ return object;
106
+ }
107
+ if (ReactElement.isValidElement(object)) {
108
+ ("production" !== process.env.NODE_ENV ? warning(
109
+ false,
110
+ 'React.addons.createFragment does not accept a ReactElement ' +
111
+ 'without a wrapper object.'
112
+ ) : null);
113
+ return object;
114
+ }
115
+ if (canWarnForReactFragment) {
116
+ var proxy = {};
117
+ Object.defineProperty(proxy, fragmentKey, {
118
+ enumerable: false,
119
+ value: object
120
+ });
121
+ Object.defineProperty(proxy, didWarnKey, {
122
+ writable: true,
123
+ enumerable: false,
124
+ value: false
125
+ });
126
+ for (var key in object) {
127
+ proxyPropertyAccessWithWarning(proxy, key);
128
+ }
129
+ Object.preventExtensions(proxy);
130
+ return proxy;
131
+ }
132
+ }
133
+ return object;
134
+ },
135
+ // Extract the original keyed object from the fragment opaque type. Warn if
136
+ // a plain object is passed here.
137
+ extract: function(fragment) {
138
+ if ("production" !== process.env.NODE_ENV) {
139
+ if (canWarnForReactFragment) {
140
+ if (!fragment[fragmentKey]) {
141
+ ("production" !== process.env.NODE_ENV ? warning(
142
+ didWarnForFragment(fragment),
143
+ 'Any use of a keyed object should be wrapped in ' +
144
+ 'React.addons.createFragment(object) before being passed as a ' +
145
+ 'child.'
146
+ ) : null);
147
+ return fragment;
148
+ }
149
+ return fragment[fragmentKey];
150
+ }
151
+ }
152
+ return fragment;
153
+ },
154
+ // Check if this is a fragment and if so, extract the keyed object. If it
155
+ // is a fragment-like object, warn that it should be wrapped. Ignore if we
156
+ // can't determine what kind of object this is.
157
+ extractIfFragment: function(fragment) {
158
+ if ("production" !== process.env.NODE_ENV) {
159
+ if (canWarnForReactFragment) {
160
+ // If it is the opaque type, return the keyed object.
161
+ if (fragment[fragmentKey]) {
162
+ return fragment[fragmentKey];
163
+ }
164
+ // Otherwise, check each property if it has an element, if it does
165
+ // it is probably meant as a fragment, so we can warn early. Defer,
166
+ // the warning to extract.
167
+ for (var key in fragment) {
168
+ if (fragment.hasOwnProperty(key) &&
169
+ ReactElement.isValidElement(fragment[key])) {
170
+ // This looks like a fragment object, we should provide an
171
+ // early warning.
172
+ return ReactFragment.extract(fragment);
173
+ }
174
+ }
175
+ }
176
+ }
177
+ return fragment;
178
+ }
179
+ };
180
+
181
+ module.exports = ReactFragment;