react 0.13.3 → 0.14.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/README.md +5 -2
  2. package/addons.js +7 -0
  3. package/dist/JSXTransformer.js +4101 -2432
  4. package/dist/react-with-addons.js +4389 -6277
  5. package/dist/react-with-addons.min.js +6 -8
  6. package/dist/react.js +4028 -5697
  7. package/dist/react.min.js +5 -6
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
  9. package/lib/BeforeInputEventPlugin.js +30 -118
  10. package/lib/CSSCore.js +12 -23
  11. package/lib/CSSProperty.js +4 -3
  12. package/lib/CSSPropertyOperations.js +14 -30
  13. package/lib/CallbackQueue.js +7 -10
  14. package/lib/ChangeEventPlugin.js +26 -88
  15. package/lib/ClientReactRootIndex.js +2 -2
  16. package/lib/DOMChildrenOperations.js +13 -33
  17. package/lib/DOMProperty.js +86 -147
  18. package/lib/DOMPropertyOperations.js +91 -67
  19. package/lib/Danger.js +19 -62
  20. package/lib/DefaultEventPluginOrder.js +2 -12
  21. package/lib/EnterLeaveEventPlugin.js +11 -33
  22. package/lib/EventConstants.js +2 -2
  23. package/lib/EventListener.js +11 -13
  24. package/lib/EventPluginHub.js +44 -47
  25. package/lib/EventPluginRegistry.js +18 -74
  26. package/lib/EventPluginUtils.js +33 -44
  27. package/lib/EventPropagators.js +23 -26
  28. package/lib/ExecutionEnvironment.js +4 -8
  29. package/lib/FallbackCompositionState.js +3 -3
  30. package/lib/HTMLDOMPropertyConfig.js +15 -20
  31. package/lib/LinkedStateMixin.js +3 -6
  32. package/lib/LinkedValueUtils.js +71 -89
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +20 -11
  35. package/lib/React.js +9 -129
  36. package/lib/ReactBrowserComponentMixin.js +9 -2
  37. package/lib/ReactBrowserEventEmitter.js +26 -82
  38. package/lib/ReactCSSTransitionGroup.js +13 -24
  39. package/lib/ReactCSSTransitionGroupChild.js +26 -28
  40. package/lib/ReactChildReconciler.js +11 -19
  41. package/lib/ReactChildren.js +24 -31
  42. package/lib/ReactClass.js +96 -267
  43. package/lib/ReactComponent.js +28 -57
  44. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  45. package/lib/ReactComponentEnvironment.js +6 -12
  46. package/lib/ReactComponentWithPureRenderMixin.js +6 -7
  47. package/lib/ReactCompositeComponent.js +115 -381
  48. package/lib/ReactCurrentOwner.js +1 -3
  49. package/lib/ReactDOM.js +4 -2
  50. package/lib/ReactDOMButton.js +16 -28
  51. package/lib/ReactDOMClient.js +90 -0
  52. package/lib/ReactDOMComponent.js +468 -156
  53. package/lib/ReactDOMIDOperations.js +25 -22
  54. package/lib/ReactDOMInput.js +79 -108
  55. package/lib/ReactDOMOption.js +58 -20
  56. package/lib/ReactDOMSelect.js +95 -83
  57. package/lib/ReactDOMSelection.js +5 -20
  58. package/lib/ReactDOMServer.js +24 -0
  59. package/lib/ReactDOMTextComponent.js +17 -18
  60. package/lib/ReactDOMTextarea.js +44 -69
  61. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  62. package/lib/ReactDefaultInjection.js +20 -76
  63. package/lib/ReactDefaultPerf.js +36 -69
  64. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  65. package/lib/ReactElement.js +26 -120
  66. package/lib/ReactElementValidator.js +56 -192
  67. package/lib/ReactEmptyComponent.js +7 -11
  68. package/lib/ReactErrorUtils.js +3 -3
  69. package/lib/ReactEventEmitterMixin.js +3 -13
  70. package/lib/ReactEventListener.js +58 -40
  71. package/lib/ReactFragment.js +33 -59
  72. package/lib/ReactInjection.js +1 -1
  73. package/lib/ReactInputSelection.js +14 -23
  74. package/lib/ReactInstanceHandles.js +29 -58
  75. package/lib/ReactInstanceMap.js +5 -5
  76. package/lib/ReactIsomorphic.js +70 -0
  77. package/lib/ReactLink.js +2 -4
  78. package/lib/ReactMarkupChecksum.js +5 -10
  79. package/lib/ReactMount.js +142 -285
  80. package/lib/ReactMultiChild.js +19 -45
  81. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  82. package/lib/ReactNativeComponent.js +6 -15
  83. package/lib/ReactNoopUpdateQueue.js +118 -0
  84. package/lib/ReactOwner.js +7 -24
  85. package/lib/ReactPerf.js +8 -12
  86. package/lib/ReactPropTransferer.js +4 -4
  87. package/lib/ReactPropTypeLocationNames.js +2 -2
  88. package/lib/ReactPropTypeLocations.js +1 -1
  89. package/lib/ReactPropTypes.js +41 -61
  90. package/lib/ReactReconcileTransaction.js +11 -36
  91. package/lib/ReactReconciler.js +14 -26
  92. package/lib/ReactRef.js +5 -8
  93. package/lib/ReactRootIndex.js +2 -2
  94. package/lib/ReactServerBatchingStrategy.js +23 -0
  95. package/lib/ReactServerRendering.js +20 -15
  96. package/lib/ReactServerRenderingTransaction.js +9 -34
  97. package/lib/ReactStateSetters.js +6 -6
  98. package/lib/ReactTestUtils.js +137 -190
  99. package/lib/ReactTransitionChildMapping.js +5 -7
  100. package/lib/ReactTransitionEvents.js +5 -5
  101. package/lib/ReactTransitionGroup.js +30 -52
  102. package/lib/ReactUpdateQueue.js +69 -107
  103. package/lib/ReactUpdates.js +26 -81
  104. package/lib/ReactWithAddons.js +5 -6
  105. package/lib/SVGDOMPropertyConfig.js +39 -4
  106. package/lib/SelectEventPlugin.js +31 -33
  107. package/lib/ServerReactRootIndex.js +2 -2
  108. package/lib/SimpleEventPlugin.js +138 -130
  109. package/lib/SyntheticClipboardEvent.js +5 -9
  110. package/lib/SyntheticCompositionEvent.js +4 -10
  111. package/lib/SyntheticDragEvent.js +3 -3
  112. package/lib/SyntheticEvent.js +14 -15
  113. package/lib/SyntheticFocusEvent.js +3 -3
  114. package/lib/SyntheticInputEvent.js +4 -10
  115. package/lib/SyntheticKeyboardEvent.js +6 -6
  116. package/lib/SyntheticMouseEvent.js +10 -16
  117. package/lib/SyntheticTouchEvent.js +3 -3
  118. package/lib/SyntheticUIEvent.js +5 -5
  119. package/lib/SyntheticWheelEvent.js +13 -17
  120. package/lib/Transaction.js +22 -28
  121. package/lib/ViewportMetrics.js +2 -2
  122. package/lib/accumulateInto.js +2 -5
  123. package/lib/adler32.js +2 -4
  124. package/lib/camelize.js +4 -2
  125. package/lib/camelizeStyleName.js +2 -2
  126. package/lib/cloneWithProps.js +6 -12
  127. package/lib/containsNode.js +29 -16
  128. package/lib/createArrayFromMixed.js +17 -16
  129. package/lib/createNodesFromMarkup.js +6 -8
  130. package/lib/dangerousStyleValue.js +2 -3
  131. package/lib/deprecated.js +47 -0
  132. package/lib/emptyFunction.js +10 -4
  133. package/lib/emptyObject.js +1 -1
  134. package/lib/escapeTextContentForBrowser.js +1 -1
  135. package/lib/findDOMNode.js +7 -27
  136. package/lib/flattenChildren.js +4 -10
  137. package/lib/focusNode.js +2 -3
  138. package/lib/forEachAccumulated.js +3 -3
  139. package/lib/getActiveElement.js +4 -2
  140. package/lib/getEventCharCode.js +2 -2
  141. package/lib/getEventKey.js +1 -1
  142. package/lib/getEventModifierState.js +1 -2
  143. package/lib/getEventTarget.js +1 -1
  144. package/lib/getIteratorFn.js +2 -4
  145. package/lib/getMarkupWrap.js +18 -40
  146. package/lib/getNodeForCharacterOffset.js +1 -1
  147. package/lib/getTextContentAccessor.js +2 -4
  148. package/lib/getUnboundedScrollPosition.js +1 -1
  149. package/lib/hyphenate.js +3 -1
  150. package/lib/hyphenateStyleName.js +2 -2
  151. package/lib/instantiateReactComponent.js +23 -43
  152. package/lib/invariant.js +8 -12
  153. package/lib/isEventSupported.js +7 -10
  154. package/lib/isNode.js +4 -6
  155. package/lib/isTextInputElement.js +3 -4
  156. package/lib/isTextNode.js +3 -1
  157. package/lib/joinClasses.js +3 -3
  158. package/lib/keyMirror.js +3 -6
  159. package/lib/keyOf.js +4 -3
  160. package/lib/mapObject.js +1 -1
  161. package/lib/memoizeStringOnly.js +2 -2
  162. package/lib/onlyChild.js +2 -5
  163. package/lib/performance.js +2 -5
  164. package/lib/performanceNow.js +3 -1
  165. package/lib/quoteAttributeValueForBrowser.js +1 -1
  166. package/lib/renderSubtreeIntoContainer.js +16 -0
  167. package/lib/setInnerHTML.js +11 -8
  168. package/lib/setTextContent.js +3 -3
  169. package/lib/shallowCompare.js +24 -0
  170. package/lib/shallowEqual.js +17 -11
  171. package/lib/shouldUpdateReactComponent.js +3 -64
  172. package/lib/toArray.js +8 -19
  173. package/lib/traverseAllChildren.js +23 -90
  174. package/lib/update.js +25 -85
  175. package/lib/validateDOMNesting.js +363 -0
  176. package/lib/warning.js +15 -17
  177. package/package.json +3 -3
  178. package/react.js +53 -1
  179. package/lib/LocalEventTrapMixin.js +0 -53
  180. package/lib/MobileSafariClickEventPlugin.js +0 -56
  181. package/lib/ReactContext.js +0 -74
  182. package/lib/ReactDOMForm.js +0 -47
  183. package/lib/ReactDOMIframe.js +0 -43
  184. package/lib/ReactDOMImg.js +0 -44
  185. package/lib/ReactLifeCycle.js +0 -35
  186. package/lib/ReactPutListenerQueue.js +0 -54
  187. package/lib/createFullPageComponent.js +0 -58
  188. package/lib/cx.js +0 -52
  189. package/lib/getReactRootElementInContainer.js +0 -33
@@ -23,7 +23,6 @@ var ReactFragment = require("./ReactFragment");
23
23
  var ReactPropTypeLocations = require("./ReactPropTypeLocations");
24
24
  var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
25
25
  var ReactCurrentOwner = require("./ReactCurrentOwner");
26
- var ReactNativeComponent = require("./ReactNativeComponent");
27
26
 
28
27
  var getIteratorFn = require("./getIteratorFn");
29
28
  var invariant = require("./invariant");
@@ -76,9 +75,7 @@ function getName(instance) {
76
75
  */
77
76
  function getCurrentOwnerDisplayName() {
78
77
  var current = ReactCurrentOwner.current;
79
- return (
80
- current && getName(current) || undefined
81
- );
78
+ return current && getName(current) || undefined;
82
79
  }
83
80
 
84
81
  /**
@@ -97,11 +94,12 @@ function validateExplicitKey(element, parentType) {
97
94
  }
98
95
  element._store.validated = true;
99
96
 
100
- warnAndMonitorForKeyUse(
101
- 'Each child in an array or iterator should have a unique "key" prop.',
102
- element,
103
- parentType
104
- );
97
+ var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
98
+ if (addenda === null) {
99
+ // we already showed the warning
100
+ return;
101
+ }
102
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
105
103
  }
106
104
 
107
105
  /**
@@ -117,59 +115,50 @@ function validatePropertyKey(name, element, parentType) {
117
115
  if (!NUMERIC_PROPERTY_REGEX.test(name)) {
118
116
  return;
119
117
  }
120
- warnAndMonitorForKeyUse(
121
- 'Child objects should have non-numeric keys so ordering is preserved.',
122
- element,
123
- parentType
124
- );
118
+ var addenda = getAddendaForKeyUse('numericKeys', element, parentType);
119
+ if (addenda === null) {
120
+ // we already showed the warning
121
+ return;
122
+ }
123
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Child objects should have non-numeric keys so ordering is preserved.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
125
124
  }
126
125
 
127
126
  /**
128
127
  * Shared warning and monitoring code for the key warnings.
129
128
  *
130
129
  * @internal
131
- * @param {string} message The base warning that gets output.
130
+ * @param {string} messageType A key used for de-duping warnings.
132
131
  * @param {ReactElement} element Component that requires a key.
133
132
  * @param {*} parentType element's parent's type.
133
+ * @returns {?object} A set of addenda to use in the warning message, or null
134
+ * if the warning has already been shown before (and shouldn't be shown again).
134
135
  */
135
- function warnAndMonitorForKeyUse(message, element, parentType) {
136
+ function getAddendaForKeyUse(messageType, element, parentType) {
136
137
  var ownerName = getCurrentOwnerDisplayName();
137
- var parentName = typeof parentType === 'string' ?
138
- parentType : parentType.displayName || parentType.name;
138
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
139
139
 
140
140
  var useName = ownerName || parentName;
141
- var memoizer = ownerHasKeyUseWarning[message] || (
142
- (ownerHasKeyUseWarning[message] = {})
143
- );
144
- if (memoizer.hasOwnProperty(useName)) {
145
- return;
141
+ var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
142
+ if (memoizer[useName]) {
143
+ return null;
146
144
  }
147
145
  memoizer[useName] = true;
148
146
 
149
- var parentOrOwnerAddendum =
150
- ownerName ? (" Check the render method of " + ownerName + ".") :
151
- parentName ? (" Check the React.render call using <" + parentName + ">.") :
152
- '';
147
+ var addenda = {
148
+ parentOrOwner: ownerName ? ' Check the render method of ' + ownerName + '.' : parentName ? ' Check the React.render call using <' + parentName + '>.' : null,
149
+ url: ' See https://fb.me/react-warning-keys for more information.',
150
+ childOwner: null
151
+ };
153
152
 
154
153
  // Usually the current owner is the offender, but if it accepts children as a
155
154
  // property, it may be the creator of the child that's responsible for
156
155
  // assigning it a key.
157
- var childOwnerAddendum = '';
158
- if (element &&
159
- element._owner &&
160
- element._owner !== ReactCurrentOwner.current) {
161
- // Name of the component that originally created this child.
162
- var childOwnerName = getName(element._owner);
163
-
164
- childOwnerAddendum = (" It was passed a child from " + childOwnerName + ".");
156
+ if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
157
+ // Give the component that originally created this child.
158
+ addenda.childOwner = ' It was passed a child from ' + getName(element._owner) + '.';
165
159
  }
166
160
 
167
- ("production" !== process.env.NODE_ENV ? warning(
168
- false,
169
- message + '%s%s See https://fb.me/react-warning-keys for more information.',
170
- parentOrOwnerAddendum,
171
- childOwnerAddendum
172
- ) : null);
161
+ return addenda;
173
162
  }
174
163
 
175
164
  /**
@@ -235,109 +224,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
235
224
  try {
236
225
  // This is intentionally an invariant that gets caught. It's the same
237
226
  // behavior as without this statement except with a better message.
238
- ("production" !== process.env.NODE_ENV ? invariant(
239
- typeof propTypes[propName] === 'function',
240
- '%s: %s type `%s` is invalid; it must be a function, usually from ' +
241
- 'React.PropTypes.',
242
- componentName || 'React class',
243
- ReactPropTypeLocationNames[location],
244
- propName
245
- ) : invariant(typeof propTypes[propName] === 'function'));
227
+ !(typeof propTypes[propName] === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
246
228
  error = propTypes[propName](props, propName, componentName, location);
247
229
  } catch (ex) {
248
230
  error = ex;
249
231
  }
232
+ 'production' !== process.env.NODE_ENV ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : undefined;
250
233
  if (error instanceof Error && !(error.message in loggedTypeFailures)) {
251
234
  // Only monitor this failure once because there tends to be a lot of the
252
235
  // same error.
253
236
  loggedTypeFailures[error.message] = true;
254
237
 
255
- var addendum = getDeclarationErrorAddendum(this);
256
- ("production" !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null);
257
- }
258
- }
259
- }
260
- }
261
-
262
- var warnedPropsMutations = {};
263
-
264
- /**
265
- * Warn about mutating props when setting `propName` on `element`.
266
- *
267
- * @param {string} propName The string key within props that was set
268
- * @param {ReactElement} element
269
- */
270
- function warnForPropsMutation(propName, element) {
271
- var type = element.type;
272
- var elementName = typeof type === 'string' ? type : type.displayName;
273
- var ownerName = element._owner ?
274
- element._owner.getPublicInstance().constructor.displayName : null;
275
-
276
- var warningKey = propName + '|' + elementName + '|' + ownerName;
277
- if (warnedPropsMutations.hasOwnProperty(warningKey)) {
278
- return;
279
- }
280
- warnedPropsMutations[warningKey] = true;
281
-
282
- var elementInfo = '';
283
- if (elementName) {
284
- elementInfo = ' <' + elementName + ' />';
285
- }
286
- var ownerInfo = '';
287
- if (ownerName) {
288
- ownerInfo = ' The element was created by ' + ownerName + '.';
289
- }
290
-
291
- ("production" !== process.env.NODE_ENV ? warning(
292
- false,
293
- 'Don\'t set .props.%s of the React component%s. Instead, specify the ' +
294
- 'correct value when initially creating the element or use ' +
295
- 'React.cloneElement to make a new element with updated props.%s',
296
- propName,
297
- elementInfo,
298
- ownerInfo
299
- ) : null);
300
- }
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
-
315
- /**
316
- * Given an element, check if its props have been mutated since element
317
- * creation (or the last call to this function). In particular, check if any
318
- * new props have been added, which we can't directly catch by defining warning
319
- * properties on the props object.
320
- *
321
- * @param {ReactElement} element
322
- */
323
- function checkAndWarnForMutatedProps(element) {
324
- if (!element._store) {
325
- // Element was created using `new ReactElement` directly or with
326
- // `ReactElement.createElement`; skip mutation checking
327
- return;
328
- }
329
-
330
- var originalProps = element._store.originalProps;
331
- var props = element.props;
332
-
333
- for (var propName in props) {
334
- if (props.hasOwnProperty(propName)) {
335
- if (!originalProps.hasOwnProperty(propName) ||
336
- !is(originalProps[propName], props[propName])) {
337
- warnForPropsMutation(propName, element);
338
-
339
- // Copy over the new value so that the two props objects match again
340
- originalProps[propName] = props[propName];
238
+ var addendum = getDeclarationErrorAddendum();
239
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
341
240
  }
342
241
  }
343
242
  }
@@ -350,48 +249,25 @@ function checkAndWarnForMutatedProps(element) {
350
249
  * @param {ReactElement} element
351
250
  */
352
251
  function validatePropTypes(element) {
353
- if (element.type == null) {
354
- // This has already warned. Don't throw.
252
+ var componentClass = element.type;
253
+ if (typeof componentClass !== 'function') {
355
254
  return;
356
255
  }
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
256
  var name = componentClass.displayName || componentClass.name;
365
257
  if (componentClass.propTypes) {
366
- checkPropTypes(
367
- name,
368
- componentClass.propTypes,
369
- element.props,
370
- ReactPropTypeLocations.prop
371
- );
258
+ checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
372
259
  }
373
260
  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);
261
+ 'production' !== process.env.NODE_ENV ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined;
379
262
  }
380
263
  }
381
264
 
382
265
  var ReactElementValidator = {
383
266
 
384
- checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
385
-
386
- createElement: function(type, props, children) {
267
+ createElement: function (type, props, children) {
387
268
  // We warn in this case but don't throw. We expect the element creation to
388
269
  // succeed and there will likely be errors in render.
389
- ("production" !== process.env.NODE_ENV ? warning(
390
- type != null,
391
- 'React.createElement: type should not be null or undefined. It should ' +
392
- 'be a string (for DOM elements) or a ReactClass (for composite ' +
393
- 'components).'
394
- ) : null);
270
+ 'production' !== process.env.NODE_ENV ? warning(typeof type === 'string' || typeof type === 'function', 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined;
395
271
 
396
272
  var element = ReactElement.createElement.apply(this, arguments);
397
273
 
@@ -410,44 +286,30 @@ var ReactElementValidator = {
410
286
  return element;
411
287
  },
412
288
 
413
- createFactory: function(type) {
414
- var validatedFactory = ReactElementValidator.createElement.bind(
415
- null,
416
- type
417
- );
289
+ createFactory: function (type) {
290
+ var validatedFactory = ReactElementValidator.createElement.bind(null, type);
418
291
  // Legacy hook TODO: Warn if this is accessed
419
292
  validatedFactory.type = type;
420
293
 
421
- if ("production" !== process.env.NODE_ENV) {
294
+ if ('production' !== process.env.NODE_ENV) {
422
295
  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
- }
296
+ Object.defineProperty(validatedFactory, 'type', {
297
+ enumerable: false,
298
+ get: function () {
299
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
300
+ Object.defineProperty(this, 'type', {
301
+ value: type
302
+ });
303
+ return type;
439
304
  }
440
- );
441
- } catch (x) {
442
- // IE will fail on defineProperty (es5-shim/sham too)
443
- }
305
+ });
306
+ } catch (x) {}
444
307
  }
445
308
 
446
-
447
309
  return validatedFactory;
448
310
  },
449
311
 
450
- cloneElement: function(element, props, children) {
312
+ cloneElement: function (element, props, children) {
451
313
  var newElement = ReactElement.cloneElement.apply(this, arguments);
452
314
  for (var i = 2; i < arguments.length; i++) {
453
315
  validateChildKeys(arguments[i], newElement.type);
@@ -459,3 +321,5 @@ var ReactElementValidator = {
459
321
  };
460
322
 
461
323
  module.exports = ReactElementValidator;
324
+
325
+ // IE will fail on defineProperty (es5-shim/sham too)
@@ -22,13 +22,13 @@ var component;
22
22
  var nullComponentIDsRegistry = {};
23
23
 
24
24
  var ReactEmptyComponentInjection = {
25
- injectEmptyComponent: function(emptyComponent) {
25
+ injectEmptyComponent: function (emptyComponent) {
26
26
  component = ReactElement.createFactory(emptyComponent);
27
27
  }
28
28
  };
29
29
 
30
- var ReactEmptyComponentType = function() {};
31
- ReactEmptyComponentType.prototype.componentDidMount = function() {
30
+ var ReactEmptyComponentType = function () {};
31
+ ReactEmptyComponentType.prototype.componentDidMount = function () {
32
32
  var internalInstance = ReactInstanceMap.get(this);
33
33
  // TODO: Make sure we run these methods in the correct order, we shouldn't
34
34
  // need this check. We're going to assume if we're here it means we ran
@@ -39,7 +39,7 @@ ReactEmptyComponentType.prototype.componentDidMount = function() {
39
39
  }
40
40
  registerNullComponentID(internalInstance._rootNodeID);
41
41
  };
42
- ReactEmptyComponentType.prototype.componentWillUnmount = function() {
42
+ ReactEmptyComponentType.prototype.componentWillUnmount = function () {
43
43
  var internalInstance = ReactInstanceMap.get(this);
44
44
  // TODO: Get rid of this check. See TODO in componentDidMount.
45
45
  if (!internalInstance) {
@@ -47,12 +47,8 @@ ReactEmptyComponentType.prototype.componentWillUnmount = function() {
47
47
  }
48
48
  deregisterNullComponentID(internalInstance._rootNodeID);
49
49
  };
50
- ReactEmptyComponentType.prototype.render = function() {
51
- ("production" !== process.env.NODE_ENV ? invariant(
52
- component,
53
- 'Trying to return null from a render, but no null placeholder component ' +
54
- 'was injected.'
55
- ) : invariant(component));
50
+ ReactEmptyComponentType.prototype.render = function () {
51
+ !component ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Trying to return null from a render, but no null placeholder component ' + 'was injected.') : invariant(false) : undefined;
56
52
  return component();
57
53
  };
58
54
 
@@ -88,4 +84,4 @@ var ReactEmptyComponent = {
88
84
  isNullComponentID: isNullComponentID
89
85
  };
90
86
 
91
- module.exports = ReactEmptyComponent;
87
+ module.exports = ReactEmptyComponent;
@@ -10,7 +10,7 @@
10
10
  * @typechecks
11
11
  */
12
12
 
13
- "use strict";
13
+ 'use strict';
14
14
 
15
15
  var ReactErrorUtils = {
16
16
  /**
@@ -22,9 +22,9 @@ var ReactErrorUtils = {
22
22
  * @param {string} name The name of the guard
23
23
  * @return {function}
24
24
  */
25
- guard: function(func, name) {
25
+ guard: function (func, name) {
26
26
  return func;
27
27
  }
28
28
  };
29
29
 
30
- module.exports = ReactErrorUtils;
30
+ module.exports = ReactErrorUtils;
@@ -29,20 +29,10 @@ var ReactEventEmitterMixin = {
29
29
  * @param {string} topLevelTargetID ID of `topLevelTarget`.
30
30
  * @param {object} nativeEvent Native environment event.
31
31
  */
32
- handleTopLevel: function(
33
- topLevelType,
34
- topLevelTarget,
35
- topLevelTargetID,
36
- nativeEvent) {
37
- var events = EventPluginHub.extractEvents(
38
- topLevelType,
39
- topLevelTarget,
40
- topLevelTargetID,
41
- nativeEvent
42
- );
43
-
32
+ handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
33
+ var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
44
34
  runEventQueueInBatch(events);
45
35
  }
46
36
  };
47
37
 
48
- module.exports = ReactEventEmitterMixin;
38
+ module.exports = ReactEventEmitterMixin;
@@ -23,6 +23,8 @@ var assign = require("./Object.assign");
23
23
  var getEventTarget = require("./getEventTarget");
24
24
  var getUnboundedScrollPosition = require("./getUnboundedScrollPosition");
25
25
 
26
+ var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
27
+
26
28
  /**
27
29
  * Finds the parent React component of `node`.
28
30
  *
@@ -48,21 +50,27 @@ function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
48
50
  this.ancestors = [];
49
51
  }
50
52
  assign(TopLevelCallbackBookKeeping.prototype, {
51
- destructor: function() {
53
+ destructor: function () {
52
54
  this.topLevelType = null;
53
55
  this.nativeEvent = null;
54
56
  this.ancestors.length = 0;
55
57
  }
56
58
  });
57
- PooledClass.addPoolingTo(
58
- TopLevelCallbackBookKeeping,
59
- PooledClass.twoArgumentPooler
60
- );
59
+ PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
61
60
 
62
61
  function handleTopLevelImpl(bookKeeping) {
63
- var topLevelTarget = ReactMount.getFirstReactDOM(
64
- getEventTarget(bookKeeping.nativeEvent)
65
- ) || window;
62
+ if (bookKeeping.nativeEvent.path) {
63
+ // New browsers have a path attribute on native events
64
+ handleTopLevelWithPath(bookKeeping);
65
+ } else {
66
+ // Legacy browsers don't have a path attribute on native events
67
+ handleTopLevelWithoutPath(bookKeeping);
68
+ }
69
+ }
70
+
71
+ // Legacy browsers don't have a path attribute on native events
72
+ function handleTopLevelWithoutPath(bookKeeping) {
73
+ var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
66
74
 
67
75
  // Loop through the hierarchy, in case there's any nested components.
68
76
  // It's important that we build the array of ancestors before calling any
@@ -74,15 +82,37 @@ function handleTopLevelImpl(bookKeeping) {
74
82
  ancestor = findParent(ancestor);
75
83
  }
76
84
 
77
- for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
85
+ for (var i = 0; i < bookKeeping.ancestors.length; i++) {
78
86
  topLevelTarget = bookKeeping.ancestors[i];
79
87
  var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
80
- ReactEventListener._handleTopLevel(
81
- bookKeeping.topLevelType,
82
- topLevelTarget,
83
- topLevelTargetID,
84
- bookKeeping.nativeEvent
85
- );
88
+ ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
89
+ }
90
+ }
91
+
92
+ // New browsers have a path attribute on native events
93
+ function handleTopLevelWithPath(bookKeeping) {
94
+ var path = bookKeeping.nativeEvent.path;
95
+ var currentNativeTarget = path[0];
96
+ for (var i = 0; i < path.length; i++) {
97
+ var currentPathElement = path[i];
98
+ var currentPathElemenId = ReactMount.getID(currentPathElement);
99
+ if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
100
+ currentNativeTarget = path[i + 1];
101
+ }
102
+ if (ReactMount.isRenderedByReact(currentPathElement)) {
103
+ var newRootId = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElemenId);
104
+ bookKeeping.ancestors.push(currentPathElement);
105
+
106
+ var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
107
+ ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
108
+
109
+ // Jump to the root of this React render tree
110
+ while (currentPathElemenId !== newRootId) {
111
+ i++;
112
+ currentPathElement = path[i];
113
+ currentPathElemenId = ReactMount.getID(currentPathElement);
114
+ }
115
+ }
86
116
  }
87
117
  }
88
118
 
@@ -97,39 +127,34 @@ var ReactEventListener = {
97
127
 
98
128
  WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
99
129
 
100
- setHandleTopLevel: function(handleTopLevel) {
130
+ setHandleTopLevel: function (handleTopLevel) {
101
131
  ReactEventListener._handleTopLevel = handleTopLevel;
102
132
  },
103
133
 
104
- setEnabled: function(enabled) {
134
+ setEnabled: function (enabled) {
105
135
  ReactEventListener._enabled = !!enabled;
106
136
  },
107
137
 
108
- isEnabled: function() {
138
+ isEnabled: function () {
109
139
  return ReactEventListener._enabled;
110
140
  },
111
141
 
112
-
113
142
  /**
114
143
  * Traps top-level events by using event bubbling.
115
144
  *
116
145
  * @param {string} topLevelType Record from `EventConstants`.
117
146
  * @param {string} handlerBaseName Event name (e.g. "click").
118
147
  * @param {object} handle Element on which to attach listener.
119
- * @return {object} An object with a remove function which will forcefully
148
+ * @return {?object} An object with a remove function which will forcefully
120
149
  * remove the listener.
121
150
  * @internal
122
151
  */
123
- trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
152
+ trapBubbledEvent: function (topLevelType, handlerBaseName, handle) {
124
153
  var element = handle;
125
154
  if (!element) {
126
155
  return null;
127
156
  }
128
- return EventListener.listen(
129
- element,
130
- handlerBaseName,
131
- ReactEventListener.dispatchEvent.bind(null, topLevelType)
132
- );
157
+ return EventListener.listen(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
133
158
  },
134
159
 
135
160
  /**
@@ -138,36 +163,29 @@ var ReactEventListener = {
138
163
  * @param {string} topLevelType Record from `EventConstants`.
139
164
  * @param {string} handlerBaseName Event name (e.g. "click").
140
165
  * @param {object} handle Element on which to attach listener.
141
- * @return {object} An object with a remove function which will forcefully
166
+ * @return {?object} An object with a remove function which will forcefully
142
167
  * remove the listener.
143
168
  * @internal
144
169
  */
145
- trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
170
+ trapCapturedEvent: function (topLevelType, handlerBaseName, handle) {
146
171
  var element = handle;
147
172
  if (!element) {
148
173
  return null;
149
174
  }
150
- return EventListener.capture(
151
- element,
152
- handlerBaseName,
153
- ReactEventListener.dispatchEvent.bind(null, topLevelType)
154
- );
175
+ return EventListener.capture(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
155
176
  },
156
177
 
157
- monitorScrollValue: function(refresh) {
178
+ monitorScrollValue: function (refresh) {
158
179
  var callback = scrollValueMonitor.bind(null, refresh);
159
180
  EventListener.listen(window, 'scroll', callback);
160
181
  },
161
182
 
162
- dispatchEvent: function(topLevelType, nativeEvent) {
183
+ dispatchEvent: function (topLevelType, nativeEvent) {
163
184
  if (!ReactEventListener._enabled) {
164
185
  return;
165
186
  }
166
187
 
167
- var bookKeeping = TopLevelCallbackBookKeeping.getPooled(
168
- topLevelType,
169
- nativeEvent
170
- );
188
+ var bookKeeping = TopLevelCallbackBookKeeping.getPooled(topLevelType, nativeEvent);
171
189
  try {
172
190
  // Event queue being processed in the same cycle allows
173
191
  // `preventDefault`.
@@ -178,4 +196,4 @@ var ReactEventListener = {
178
196
  }
179
197
  };
180
198
 
181
- module.exports = ReactEventListener;
199
+ module.exports = ReactEventListener;