react 0.14.0-alpha1 → 0.14.0-beta2

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 (195) hide show
  1. package/README.md +5 -2
  2. package/addons.js +5 -2
  3. package/dist/JSXTransformer.js +634 -274
  4. package/dist/react-with-addons.js +5376 -4800
  5. package/dist/react-with-addons.min.js +6 -6
  6. package/dist/react.js +5175 -4626
  7. package/dist/react.min.js +6 -5
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
  9. package/lib/BeforeInputEventPlugin.js +13 -13
  10. package/lib/CSSProperty.js +3 -0
  11. package/lib/CSSPropertyOperations.js +13 -13
  12. package/lib/CallbackQueue.js +4 -4
  13. package/lib/ChangeEventPlugin.js +16 -14
  14. package/lib/DOMChildrenOperations.js +10 -6
  15. package/lib/DOMProperty.js +82 -119
  16. package/lib/DOMPropertyOperations.js +78 -33
  17. package/lib/Danger.js +14 -16
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +8 -8
  20. package/lib/EventConstants.js +23 -1
  21. package/lib/EventPluginHub.js +13 -13
  22. package/lib/EventPluginRegistry.js +8 -8
  23. package/lib/EventPluginUtils.js +17 -17
  24. package/lib/EventPropagators.js +7 -7
  25. package/lib/FallbackCompositionState.js +3 -3
  26. package/lib/HTMLDOMPropertyConfig.js +14 -5
  27. package/lib/LinkedStateMixin.js +2 -2
  28. package/lib/LinkedValueUtils.js +50 -38
  29. package/lib/MetaMatchers.js +118 -0
  30. package/lib/OrderedMap.js +453 -0
  31. package/lib/PooledClass.js +14 -2
  32. package/lib/React.js +9 -111
  33. package/lib/ReactBrowserComponentMixin.js +4 -4
  34. package/lib/ReactBrowserEventEmitter.js +30 -7
  35. package/lib/ReactCSSTransitionGroup.js +16 -5
  36. package/lib/ReactCSSTransitionGroupChild.js +20 -11
  37. package/lib/ReactChildReconciler.js +25 -18
  38. package/lib/ReactChildren.js +24 -22
  39. package/lib/ReactClass.js +68 -86
  40. package/lib/ReactComponent.js +22 -17
  41. package/lib/ReactComponentBrowserEnvironment.js +2 -4
  42. package/lib/ReactComponentEnvironment.js +2 -2
  43. package/lib/ReactComponentWithPureRenderMixin.js +3 -3
  44. package/lib/ReactCompositeComponent.js +80 -111
  45. package/lib/ReactDOM.js +72 -158
  46. package/lib/ReactDOMButton.js +15 -26
  47. package/lib/ReactDOMComponent.js +384 -62
  48. package/lib/ReactDOMFactories.js +177 -0
  49. package/lib/ReactDOMIDOperations.js +23 -25
  50. package/lib/ReactDOMInput.js +83 -99
  51. package/lib/ReactDOMOption.js +38 -42
  52. package/lib/ReactDOMSelect.js +88 -98
  53. package/lib/ReactDOMSelection.js +3 -3
  54. package/lib/ReactDOMServer.js +24 -0
  55. package/lib/ReactDOMTextComponent.js +13 -13
  56. package/lib/ReactDOMTextarea.js +48 -61
  57. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  58. package/lib/ReactDefaultInjection.js +34 -71
  59. package/lib/ReactDefaultPerf.js +7 -7
  60. package/lib/ReactDefaultPerfAnalysis.js +6 -9
  61. package/lib/ReactElement.js +35 -92
  62. package/lib/ReactElementValidator.js +53 -130
  63. package/lib/ReactEmptyComponent.js +4 -4
  64. package/lib/ReactErrorUtils.js +1 -1
  65. package/lib/ReactEventEmitterMixin.js +3 -4
  66. package/lib/ReactEventListener.js +57 -12
  67. package/lib/ReactFragment.js +22 -17
  68. package/lib/ReactInjection.js +11 -11
  69. package/lib/ReactInputSelection.js +8 -7
  70. package/lib/ReactInstanceHandles.js +12 -12
  71. package/lib/ReactIsomorphic.js +70 -0
  72. package/lib/ReactLink.js +1 -1
  73. package/lib/ReactMarkupChecksum.js +6 -2
  74. package/lib/ReactMount.js +90 -89
  75. package/lib/ReactMultiChild.js +83 -22
  76. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  77. package/lib/ReactNativeComponent.js +3 -8
  78. package/lib/ReactNoopUpdateQueue.js +118 -0
  79. package/lib/ReactOwner.js +3 -3
  80. package/lib/ReactPerf.js +2 -2
  81. package/lib/ReactPropTransferer.js +3 -3
  82. package/lib/ReactPropTypeLocationNames.js +1 -1
  83. package/lib/ReactPropTypeLocations.js +1 -1
  84. package/lib/ReactPropTypes.js +72 -33
  85. package/lib/ReactReconcileTransaction.js +8 -8
  86. package/lib/ReactReconciler.js +18 -20
  87. package/lib/ReactRef.js +1 -1
  88. package/lib/ReactServerBatchingStrategy.js +23 -0
  89. package/lib/ReactServerRendering.js +22 -9
  90. package/lib/ReactServerRenderingTransaction.js +7 -7
  91. package/lib/ReactTestUtils.js +80 -58
  92. package/lib/ReactTransitionChildMapping.js +2 -2
  93. package/lib/ReactTransitionEvents.js +1 -1
  94. package/lib/ReactTransitionGroup.js +5 -6
  95. package/lib/ReactUpdateQueue.js +61 -36
  96. package/lib/ReactUpdates.js +14 -17
  97. package/lib/ReactWithAddons.js +14 -16
  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 -3
  102. package/lib/SelectEventPlugin.js +14 -15
  103. package/lib/SimpleEventPlugin.js +205 -29
  104. package/lib/SyntheticClipboardEvent.js +3 -3
  105. package/lib/SyntheticCompositionEvent.js +3 -3
  106. package/lib/SyntheticDragEvent.js +3 -3
  107. package/lib/SyntheticEvent.js +9 -8
  108. package/lib/SyntheticFocusEvent.js +3 -3
  109. package/lib/SyntheticInputEvent.js +3 -3
  110. package/lib/SyntheticKeyboardEvent.js +6 -6
  111. package/lib/SyntheticMouseEvent.js +5 -5
  112. package/lib/SyntheticTouchEvent.js +4 -4
  113. package/lib/SyntheticUIEvent.js +4 -4
  114. package/lib/SyntheticWheelEvent.js +3 -3
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +16 -10
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -9
  120. package/lib/cloneWithProps.js +12 -7
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +47 -0
  124. package/lib/findDOMNode.js +11 -12
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/forEachAccumulated.js +1 -1
  127. package/lib/getEventCharCode.js +1 -1
  128. package/lib/getEventKey.js +1 -1
  129. package/lib/getEventModifierState.js +0 -1
  130. package/lib/getTestDocument.js +28 -0
  131. package/lib/getTextContentAccessor.js +1 -1
  132. package/lib/instantiateReactComponent.js +24 -20
  133. package/lib/isEventSupported.js +1 -1
  134. package/lib/isTextInputElement.js +2 -1
  135. package/lib/joinClasses.js +1 -1
  136. package/lib/onlyChild.js +3 -3
  137. package/lib/quoteAttributeValueForBrowser.js +1 -1
  138. package/lib/reactComponentExpect.js +210 -0
  139. package/lib/renderSubtreeIntoContainer.js +1 -1
  140. package/lib/setInnerHTML.js +2 -2
  141. package/lib/setTextContent.js +3 -3
  142. package/lib/shallowCompare.js +1 -1
  143. package/lib/sliceChildren.js +51 -0
  144. package/lib/traverseAllChildren.js +24 -27
  145. package/lib/update.js +13 -13
  146. package/lib/validateDOMNesting.js +199 -100
  147. package/lib/webcomponents.js +6379 -0
  148. package/package.json +4 -6
  149. package/react.js +53 -1
  150. package/addons/CSSTransitionGroup.js +0 -1
  151. package/addons/LinkedStateMixin.js +0 -1
  152. package/addons/Perf.js +0 -1
  153. package/addons/PureRenderMixin.js +0 -1
  154. package/addons/TestUtils.js +0 -1
  155. package/addons/TransitionGroup.js +0 -1
  156. package/addons/batchedUpdates.js +0 -1
  157. package/addons/cloneWithProps.js +0 -1
  158. package/addons/createFragment.js +0 -1
  159. package/addons/renderSubtreeIntoContainer.js +0 -1
  160. package/addons/shallowCompare.js +0 -1
  161. package/addons/update.js +0 -1
  162. package/lib/CSSCore.js +0 -97
  163. package/lib/EventListener.js +0 -84
  164. package/lib/ExecutionEnvironment.js +0 -38
  165. package/lib/LocalEventTrapMixin.js +0 -46
  166. package/lib/ReactContext.js +0 -32
  167. package/lib/ReactDOMForm.js +0 -47
  168. package/lib/ReactDOMIframe.js +0 -43
  169. package/lib/ReactDOMImg.js +0 -44
  170. package/lib/ReactLifeCycle.js +0 -35
  171. package/lib/camelize.js +0 -32
  172. package/lib/camelizeStyleName.js +0 -40
  173. package/lib/containsNode.js +0 -55
  174. package/lib/createArrayFromMixed.js +0 -85
  175. package/lib/createFullPageComponent.js +0 -51
  176. package/lib/createNodesFromMarkup.js +0 -84
  177. package/lib/emptyFunction.js +0 -38
  178. package/lib/emptyObject.js +0 -20
  179. package/lib/focusNode.js +0 -26
  180. package/lib/getActiveElement.js +0 -29
  181. package/lib/getMarkupWrap.js +0 -115
  182. package/lib/getUnboundedScrollPosition.js +0 -38
  183. package/lib/hyphenate.js +0 -33
  184. package/lib/hyphenateStyleName.js +0 -39
  185. package/lib/invariant.js +0 -49
  186. package/lib/isNode.js +0 -23
  187. package/lib/isTextNode.js +0 -25
  188. package/lib/keyMirror.js +0 -48
  189. package/lib/keyOf.js +0 -35
  190. package/lib/mapObject.js +0 -51
  191. package/lib/performance.js +0 -23
  192. package/lib/performanceNow.js +0 -28
  193. package/lib/shallowEqual.js +0 -48
  194. package/lib/toArray.js +0 -57
  195. package/lib/warning.js +0 -61
@@ -18,16 +18,15 @@
18
18
 
19
19
  'use strict';
20
20
 
21
- var ReactElement = require("./ReactElement");
22
- var ReactFragment = require("./ReactFragment");
23
- var ReactPropTypeLocations = require("./ReactPropTypeLocations");
24
- var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
25
- var ReactCurrentOwner = require("./ReactCurrentOwner");
26
- var ReactNativeComponent = require("./ReactNativeComponent");
21
+ var ReactElement = require('./ReactElement');
22
+ var ReactFragment = require('./ReactFragment');
23
+ var ReactPropTypeLocations = require('./ReactPropTypeLocations');
24
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
25
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
27
26
 
28
- var getIteratorFn = require("./getIteratorFn");
29
- var invariant = require("./invariant");
30
- var warning = require("./warning");
27
+ var getIteratorFn = require('./getIteratorFn');
28
+ var invariant = require('fbjs/lib/invariant');
29
+ var warning = require('fbjs/lib/warning');
31
30
 
32
31
  function getDeclarationErrorAddendum() {
33
32
  if (ReactCurrentOwner.current) {
@@ -90,10 +89,17 @@ function getCurrentOwnerDisplayName() {
90
89
  * @param {*} parentType element's parent's type.
91
90
  */
92
91
  function validateExplicitKey(element, parentType) {
93
- if (element.key != null) {
92
+ if (element._store.validated || element.key != null) {
94
93
  return;
95
94
  }
96
- warnAndMonitorForKeyUse('Each child in an array or iterator should have a unique "key" prop.', element, parentType);
95
+ element._store.validated = true;
96
+
97
+ var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
98
+ if (addenda === null) {
99
+ // we already showed the warning
100
+ return;
101
+ }
102
+ process.env.NODE_ENV !== 'production' ? 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;
97
103
  }
98
104
 
99
105
  /**
@@ -109,42 +115,50 @@ function validatePropertyKey(name, element, parentType) {
109
115
  if (!NUMERIC_PROPERTY_REGEX.test(name)) {
110
116
  return;
111
117
  }
112
- warnAndMonitorForKeyUse('Child objects should have non-numeric keys so ordering is preserved.', element, parentType);
118
+ var addenda = getAddendaForKeyUse('numericKeys', element, parentType);
119
+ if (addenda === null) {
120
+ // we already showed the warning
121
+ return;
122
+ }
123
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Child objects should have non-numeric keys so ordering is preserved.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
113
124
  }
114
125
 
115
126
  /**
116
127
  * Shared warning and monitoring code for the key warnings.
117
128
  *
118
129
  * @internal
119
- * @param {string} message The base warning that gets output.
130
+ * @param {string} messageType A key used for de-duping warnings.
120
131
  * @param {ReactElement} element Component that requires a key.
121
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).
122
135
  */
123
- function warnAndMonitorForKeyUse(message, element, parentType) {
136
+ function getAddendaForKeyUse(messageType, element, parentType) {
124
137
  var ownerName = getCurrentOwnerDisplayName();
125
138
  var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
126
139
 
127
140
  var useName = ownerName || parentName;
128
- var memoizer = ownerHasKeyUseWarning[message] || (ownerHasKeyUseWarning[message] = {});
129
- if (memoizer.hasOwnProperty(useName)) {
130
- return;
141
+ var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
142
+ if (memoizer[useName]) {
143
+ return null;
131
144
  }
132
145
  memoizer[useName] = true;
133
146
 
134
- var parentOrOwnerAddendum = ownerName ? ' Check the render method of ' + ownerName + '.' : parentName ? ' Check the React.render call using <' + parentName + '>.' : '';
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
+ };
135
152
 
136
153
  // Usually the current owner is the offender, but if it accepts children as a
137
154
  // property, it may be the creator of the child that's responsible for
138
155
  // assigning it a key.
139
- var childOwnerAddendum = '';
140
156
  if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
141
- // Name of the component that originally created this child.
142
- var childOwnerName = getName(element._owner);
143
-
144
- childOwnerAddendum = ' It was passed a child from ' + childOwnerName + '.';
157
+ // Give the component that originally created this child.
158
+ addenda.childOwner = ' It was passed a child from ' + getName(element._owner) + '.';
145
159
  }
146
160
 
147
- 'production' !== process.env.NODE_ENV ? warning(false, message + '%s%s See https://fb.me/react-warning-keys for more information.', parentOrOwnerAddendum, childOwnerAddendum) : null;
161
+ return addenda;
148
162
  }
149
163
 
150
164
  /**
@@ -158,22 +172,15 @@ function warnAndMonitorForKeyUse(message, element, parentType) {
158
172
  */
159
173
  function validateChildKeys(node, parentType) {
160
174
  if (Array.isArray(node)) {
161
- if (node._reactChildKeysValidated) {
162
- // All child elements were passed in a valid location.
163
- return;
164
- }
165
175
  for (var i = 0; i < node.length; i++) {
166
176
  var child = node[i];
167
177
  if (ReactElement.isValidElement(child)) {
168
178
  validateExplicitKey(child, parentType);
169
- } else {
170
- // TODO: Warn on unkeyed arrays and suggest using createFragment
171
- validateChildKeys(child, parentType);
172
179
  }
173
180
  }
174
- } else if (typeof node === 'string' || typeof node === 'number' || ReactElement.isValidElement(node)) {
181
+ } else if (ReactElement.isValidElement(node)) {
175
182
  // This element was passed in a valid location.
176
- return;
183
+ node._store.validated = true;
177
184
  } else if (node) {
178
185
  var iteratorFn = getIteratorFn(node);
179
186
  // Entry iterators provide implicit keys.
@@ -184,8 +191,6 @@ function validateChildKeys(node, parentType) {
184
191
  while (!(step = iterator.next()).done) {
185
192
  if (ReactElement.isValidElement(step.value)) {
186
193
  validateExplicitKey(step.value, parentType);
187
- } else {
188
- validateChildKeys(step.value, parentType);
189
194
  }
190
195
  }
191
196
  }
@@ -194,7 +199,6 @@ function validateChildKeys(node, parentType) {
194
199
  for (var key in fragment) {
195
200
  if (fragment.hasOwnProperty(key)) {
196
201
  validatePropertyKey(key, fragment[key], parentType);
197
- validateChildKeys(fragment[key], parentType);
198
202
  }
199
203
  }
200
204
  }
@@ -220,93 +224,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
220
224
  try {
221
225
  // This is intentionally an invariant that gets caught. It's the same
222
226
  // behavior as without this statement except with a better message.
223
- 'production' !== process.env.NODE_ENV ? invariant(typeof propTypes[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(typeof propTypes[propName] === 'function');
227
+ !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? 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;
224
228
  error = propTypes[propName](props, propName, componentName, location);
225
229
  } catch (ex) {
226
230
  error = ex;
227
231
  }
228
- '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) : null;
232
+ process.env.NODE_ENV !== 'production' ? 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;
229
233
  if (error instanceof Error && !(error.message in loggedTypeFailures)) {
230
234
  // Only monitor this failure once because there tends to be a lot of the
231
235
  // same error.
232
236
  loggedTypeFailures[error.message] = true;
233
237
 
234
238
  var addendum = getDeclarationErrorAddendum();
235
- 'production' !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null;
236
- }
237
- }
238
- }
239
- }
240
-
241
- var warnedPropsMutations = {};
242
-
243
- /**
244
- * Warn about mutating props when setting `propName` on `element`.
245
- *
246
- * @param {string} propName The string key within props that was set
247
- * @param {ReactElement} element
248
- */
249
- function warnForPropsMutation(propName, element) {
250
- var type = element.type;
251
- var elementName = typeof type === 'string' ? type : type.displayName;
252
- var ownerName = element._owner ? element._owner.getPublicInstance().constructor.displayName : null;
253
-
254
- var warningKey = propName + '|' + elementName + '|' + ownerName;
255
- if (warnedPropsMutations.hasOwnProperty(warningKey)) {
256
- return;
257
- }
258
- warnedPropsMutations[warningKey] = true;
259
-
260
- var elementInfo = '';
261
- if (elementName) {
262
- elementInfo = ' <' + elementName + ' />';
263
- }
264
- var ownerInfo = '';
265
- if (ownerName) {
266
- ownerInfo = ' The element was created by ' + ownerName + '.';
267
- }
268
-
269
- 'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set .props.%s of the React component%s. Instead, specify the ' + 'correct value when initially creating the element or use ' + 'React.cloneElement to make a new element with updated props.%s', propName, elementInfo, ownerInfo) : null;
270
- }
271
-
272
- // Inline Object.is polyfill
273
- function is(a, b) {
274
- if (a !== a) {
275
- // NaN
276
- return b !== b;
277
- }
278
- if (a === 0 && b === 0) {
279
- // +-0
280
- return 1 / a === 1 / b;
281
- }
282
- return a === b;
283
- }
284
-
285
- /**
286
- * Given an element, check if its props have been mutated since element
287
- * creation (or the last call to this function). In particular, check if any
288
- * new props have been added, which we can't directly catch by defining warning
289
- * properties on the props object.
290
- *
291
- * @param {ReactElement} element
292
- */
293
- function checkAndWarnForMutatedProps(element) {
294
- if (!element._store) {
295
- // Element was created using `new ReactElement` directly or with
296
- // `ReactElement.createElement`; skip mutation checking
297
- return;
298
- }
299
-
300
- var originalProps = element._store.originalProps;
301
- var props = element.props;
302
-
303
- for (var propName in props) {
304
- if (props.hasOwnProperty(propName)) {
305
- if (!originalProps.hasOwnProperty(propName) || !is(originalProps[propName], props[propName])) {
306
- warnForPropsMutation(propName, element);
307
-
308
- // Copy over the new value so that the two props objects match again
309
- originalProps[propName] = props[propName];
239
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
310
240
  }
311
241
  }
312
242
  }
@@ -319,32 +249,25 @@ function checkAndWarnForMutatedProps(element) {
319
249
  * @param {ReactElement} element
320
250
  */
321
251
  function validatePropTypes(element) {
322
- if (!(typeof element.type === 'string' || typeof element.type === 'function')) {
323
- // This has already warned. Don't throw.
252
+ var componentClass = element.type;
253
+ if (typeof componentClass !== 'function') {
324
254
  return;
325
255
  }
326
- // Extract the component class from the element. Converts string types
327
- // to a composite class which may have propTypes.
328
- // TODO: Validating a string's propTypes is not decoupled from the
329
- // rendering target which is problematic.
330
- var componentClass = ReactNativeComponent.getComponentClassForElement(element);
331
256
  var name = componentClass.displayName || componentClass.name;
332
257
  if (componentClass.propTypes) {
333
258
  checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
334
259
  }
335
260
  if (typeof componentClass.getDefaultProps === 'function') {
336
- '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.') : null;
261
+ process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined;
337
262
  }
338
263
  }
339
264
 
340
265
  var ReactElementValidator = {
341
266
 
342
- checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
343
-
344
267
  createElement: function (type, props, children) {
345
268
  // We warn in this case but don't throw. We expect the element creation to
346
269
  // succeed and there will likely be errors in render.
347
- '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()) : null;
270
+ process.env.NODE_ENV !== 'production' ? 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;
348
271
 
349
272
  var element = ReactElement.createElement.apply(this, arguments);
350
273
 
@@ -368,19 +291,21 @@ var ReactElementValidator = {
368
291
  // Legacy hook TODO: Warn if this is accessed
369
292
  validatedFactory.type = type;
370
293
 
371
- if ('production' !== process.env.NODE_ENV) {
294
+ if (process.env.NODE_ENV !== 'production') {
372
295
  try {
373
296
  Object.defineProperty(validatedFactory, 'type', {
374
297
  enumerable: false,
375
298
  get: function () {
376
- 'production' !== process.env.NODE_ENV ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : null;
299
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
377
300
  Object.defineProperty(this, 'type', {
378
301
  value: type
379
302
  });
380
303
  return type;
381
304
  }
382
305
  });
383
- } catch (x) {}
306
+ } catch (x) {
307
+ // IE will fail on defineProperty (es5-shim/sham too)
308
+ }
384
309
  }
385
310
 
386
311
  return validatedFactory;
@@ -397,6 +322,4 @@ var ReactElementValidator = {
397
322
 
398
323
  };
399
324
 
400
- module.exports = ReactElementValidator;
401
-
402
- // IE will fail on defineProperty (es5-shim/sham too)
325
+ module.exports = ReactElementValidator;
@@ -11,10 +11,10 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactElement = require("./ReactElement");
15
- var ReactInstanceMap = require("./ReactInstanceMap");
14
+ var ReactElement = require('./ReactElement');
15
+ var ReactInstanceMap = require('./ReactInstanceMap');
16
16
 
17
- var invariant = require("./invariant");
17
+ var invariant = require('fbjs/lib/invariant');
18
18
 
19
19
  var component;
20
20
  // This registry keeps track of the React IDs of the components that rendered to
@@ -48,7 +48,7 @@ ReactEmptyComponentType.prototype.componentWillUnmount = function () {
48
48
  deregisterNullComponentID(internalInstance._rootNodeID);
49
49
  };
50
50
  ReactEmptyComponentType.prototype.render = function () {
51
- 'production' !== process.env.NODE_ENV ? invariant(component, 'Trying to return null from a render, but no null placeholder component ' + 'was injected.') : invariant(component);
51
+ !component ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to return null from a render, but no null placeholder component ' + 'was injected.') : invariant(false) : undefined;
52
52
  return component();
53
53
  };
54
54
 
@@ -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
  /**
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var EventPluginHub = require("./EventPluginHub");
14
+ var EventPluginHub = require('./EventPluginHub');
15
15
 
16
16
  function runEventQueueInBatch(events) {
17
17
  EventPluginHub.enqueueEvents(events);
@@ -29,9 +29,8 @@ var ReactEventEmitterMixin = {
29
29
  * @param {string} topLevelTargetID ID of `topLevelTarget`.
30
30
  * @param {object} nativeEvent Native environment event.
31
31
  */
32
- handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
33
- var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent);
34
-
32
+ handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
33
+ var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
35
34
  runEventQueueInBatch(events);
36
35
  }
37
36
  };
@@ -12,16 +12,18 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var EventListener = require("./EventListener");
16
- var ExecutionEnvironment = require("./ExecutionEnvironment");
17
- var PooledClass = require("./PooledClass");
18
- var ReactInstanceHandles = require("./ReactInstanceHandles");
19
- var ReactMount = require("./ReactMount");
20
- var ReactUpdates = require("./ReactUpdates");
15
+ var EventListener = require('fbjs/lib/EventListener');
16
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
17
+ var PooledClass = require('./PooledClass');
18
+ var ReactInstanceHandles = require('./ReactInstanceHandles');
19
+ var ReactMount = require('./ReactMount');
20
+ var ReactUpdates = require('./ReactUpdates');
21
21
 
22
- var assign = require("./Object.assign");
23
- var getEventTarget = require("./getEventTarget");
24
- var getUnboundedScrollPosition = require("./getUnboundedScrollPosition");
22
+ var assign = require('./Object.assign');
23
+ var getEventTarget = require('./getEventTarget');
24
+ var getUnboundedScrollPosition = require('fbjs/lib/getUnboundedScrollPosition');
25
+
26
+ var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
25
27
 
26
28
  /**
27
29
  * Finds the parent React component of `node`.
@@ -57,6 +59,17 @@ assign(TopLevelCallbackBookKeeping.prototype, {
57
59
  PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
58
60
 
59
61
  function handleTopLevelImpl(bookKeeping) {
62
+ if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
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) {
60
73
  var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
61
74
 
62
75
  // Loop through the hierarchy, in case there's any nested components.
@@ -72,7 +85,39 @@ function handleTopLevelImpl(bookKeeping) {
72
85
  for (var i = 0; i < bookKeeping.ancestors.length; i++) {
73
86
  topLevelTarget = bookKeeping.ancestors[i];
74
87
  var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
75
- ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent);
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
+ var eventsFired = 0;
97
+ for (var i = 0; i < path.length; i++) {
98
+ var currentPathElement = path[i];
99
+ var currentPathElementID = ReactMount.getID(currentPathElement);
100
+ if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
101
+ currentNativeTarget = path[i + 1];
102
+ }
103
+ if (ReactMount.isRenderedByReact(currentPathElement)) {
104
+ var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID);
105
+ bookKeeping.ancestors.push(currentPathElement);
106
+
107
+ var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
108
+ eventsFired++;
109
+ ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
110
+
111
+ // Jump to the root of this React render tree
112
+ while (currentPathElementID !== newRootID) {
113
+ i++;
114
+ currentPathElement = path[i];
115
+ currentPathElementID = ReactMount.getID(currentPathElement);
116
+ }
117
+ }
118
+ }
119
+ if (eventsFired === 0) {
120
+ ReactEventListener._handleTopLevel(bookKeeping.topLevelType, window, '', bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
76
121
  }
77
122
  }
78
123
 
@@ -105,7 +150,7 @@ var ReactEventListener = {
105
150
  * @param {string} topLevelType Record from `EventConstants`.
106
151
  * @param {string} handlerBaseName Event name (e.g. "click").
107
152
  * @param {object} handle Element on which to attach listener.
108
- * @return {object} An object with a remove function which will forcefully
153
+ * @return {?object} An object with a remove function which will forcefully
109
154
  * remove the listener.
110
155
  * @internal
111
156
  */
@@ -123,7 +168,7 @@ var ReactEventListener = {
123
168
  * @param {string} topLevelType Record from `EventConstants`.
124
169
  * @param {string} handlerBaseName Event name (e.g. "click").
125
170
  * @param {object} handle Element on which to attach listener.
126
- * @return {object} An object with a remove function which will forcefully
171
+ * @return {?object} An object with a remove function which will forcefully
127
172
  * remove the listener.
128
173
  * @internal
129
174
  */