react 0.14.8 → 15.0.0-rc.1

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 (184) hide show
  1. package/LICENSE +1 -1
  2. package/addons.js +2 -0
  3. package/dist/react-with-addons.js +4203 -4148
  4. package/dist/react-with-addons.min.js +7 -7
  5. package/dist/react.js +4159 -3850
  6. package/dist/react.min.js +7 -7
  7. package/lib/AutoFocusUtils.js +3 -15
  8. package/lib/BeforeInputEventPlugin.js +8 -25
  9. package/lib/CSSProperty.js +4 -1
  10. package/lib/CSSPropertyOperations.js +24 -10
  11. package/lib/CallbackQueue.js +13 -2
  12. package/lib/ChangeEventPlugin.js +58 -54
  13. package/lib/DOMChildrenOperations.js +93 -60
  14. package/lib/DOMLazyTree.js +96 -0
  15. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  16. package/lib/DOMProperty.js +18 -39
  17. package/lib/DOMPropertyOperations.js +87 -53
  18. package/lib/Danger.js +13 -14
  19. package/lib/DefaultEventPluginOrder.js +1 -1
  20. package/lib/EnterLeaveEventPlugin.js +24 -43
  21. package/lib/EventConstants.js +6 -1
  22. package/lib/EventPluginHub.js +22 -66
  23. package/lib/EventPluginRegistry.js +30 -9
  24. package/lib/EventPluginUtils.js +61 -36
  25. package/lib/EventPropagators.js +19 -17
  26. package/lib/FallbackCompositionState.js +1 -2
  27. package/lib/HTMLDOMPropertyConfig.js +69 -90
  28. package/lib/LinkedStateMixin.js +1 -2
  29. package/lib/LinkedValueUtils.js +5 -6
  30. package/lib/MetaMatchers.js +2 -2
  31. package/lib/Object.assign.js +1 -1
  32. package/lib/OrderedMap.js +14 -14
  33. package/lib/PooledClass.js +2 -2
  34. package/lib/React.js +1 -13
  35. package/lib/ReactBrowserEventEmitter.js +16 -24
  36. package/lib/ReactCSSTransitionGroup.js +1 -2
  37. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  38. package/lib/ReactChildReconciler.js +15 -13
  39. package/lib/ReactChildren.js +5 -4
  40. package/lib/ReactClass.js +37 -86
  41. package/lib/ReactComponent.js +7 -8
  42. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  43. package/lib/ReactComponentEnvironment.js +4 -4
  44. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  45. package/lib/ReactCompositeComponent.js +160 -69
  46. package/lib/ReactCurrentOwner.js +2 -1
  47. package/lib/ReactDOM.js +27 -15
  48. package/lib/ReactDOMButton.js +2 -2
  49. package/lib/ReactDOMComponent.js +188 -244
  50. package/lib/ReactDOMComponentFlags.js +18 -0
  51. package/lib/ReactDOMComponentTree.js +186 -0
  52. package/lib/ReactDOMContainerInfo.js +32 -0
  53. package/lib/ReactDOMDebugTool.js +69 -0
  54. package/lib/ReactDOMEmptyComponent.js +60 -0
  55. package/lib/ReactDOMFactories.js +1 -2
  56. package/lib/ReactDOMFeatureFlags.js +2 -2
  57. package/lib/ReactDOMIDOperations.js +5 -60
  58. package/lib/ReactDOMInput.js +71 -22
  59. package/lib/ReactDOMInstrumentation.js +16 -0
  60. package/lib/ReactDOMOption.js +11 -10
  61. package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +61 -0
  62. package/lib/ReactDOMSelect.js +40 -17
  63. package/lib/ReactDOMSelection.js +4 -4
  64. package/lib/ReactDOMServer.js +1 -1
  65. package/lib/ReactDOMTextComponent.js +84 -43
  66. package/lib/ReactDOMTextarea.js +36 -9
  67. package/lib/ReactDOMTreeTraversal.js +134 -0
  68. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  69. package/lib/ReactDebugTool.js +72 -0
  70. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  71. package/lib/ReactDefaultInjection.js +11 -15
  72. package/lib/ReactDefaultPerf.js +59 -19
  73. package/lib/ReactDefaultPerfAnalysis.js +17 -9
  74. package/lib/ReactElement.js +60 -21
  75. package/lib/ReactElementValidator.js +8 -8
  76. package/lib/ReactEmptyComponent.js +8 -33
  77. package/lib/ReactErrorUtils.js +1 -2
  78. package/lib/ReactEventEmitterMixin.js +3 -8
  79. package/lib/ReactEventListener.js +20 -75
  80. package/lib/ReactFeatureFlags.js +21 -0
  81. package/lib/ReactFragment.js +6 -6
  82. package/lib/ReactInjection.js +3 -3
  83. package/lib/ReactInputSelection.js +4 -4
  84. package/lib/ReactInstanceHandles.js +10 -12
  85. package/lib/ReactInstanceMap.js +2 -1
  86. package/lib/ReactInstrumentation.js +16 -0
  87. package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
  88. package/lib/ReactIsomorphic.js +1 -1
  89. package/lib/ReactLink.js +2 -3
  90. package/lib/ReactMarkupChecksum.js +1 -1
  91. package/lib/ReactMount.js +87 -460
  92. package/lib/ReactMultiChild.js +106 -200
  93. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  94. package/lib/ReactNativeComponent.js +3 -3
  95. package/lib/ReactNodeTypes.js +37 -0
  96. package/lib/ReactNoopUpdateQueue.js +2 -25
  97. package/lib/ReactOwner.js +3 -3
  98. package/lib/ReactPerf.js +2 -2
  99. package/lib/ReactPropTransferer.js +1 -1
  100. package/lib/ReactPropTypeLocationNames.js +1 -1
  101. package/lib/ReactPropTypeLocations.js +1 -1
  102. package/lib/ReactPropTypes.js +27 -3
  103. package/lib/ReactReconcileTransaction.js +17 -6
  104. package/lib/ReactReconciler.js +29 -6
  105. package/lib/ReactRef.js +1 -1
  106. package/lib/ReactServerBatchingStrategy.js +1 -2
  107. package/lib/ReactServerRendering.js +17 -35
  108. package/lib/ReactServerRenderingTransaction.js +8 -26
  109. package/lib/ReactSimpleEmptyComponent.js +36 -0
  110. package/lib/ReactStateSetters.js +1 -1
  111. package/lib/ReactTestUtils.js +33 -24
  112. package/lib/ReactTransitionChildMapping.js +1 -2
  113. package/lib/ReactTransitionEvents.js +8 -44
  114. package/lib/ReactTransitionGroup.js +1 -1
  115. package/lib/ReactUpdateQueue.js +6 -65
  116. package/lib/ReactUpdates.js +26 -9
  117. package/lib/ReactVersion.js +2 -2
  118. package/lib/ReactWithAddons.js +1 -14
  119. package/lib/ResponderEventPlugin.js +54 -66
  120. package/lib/ResponderSyntheticEvent.js +1 -2
  121. package/lib/ResponderTouchHistoryStore.js +5 -5
  122. package/lib/SVGDOMPropertyConfig.js +25 -66
  123. package/lib/SelectEventPlugin.js +13 -18
  124. package/lib/SimpleEventPlugin.js +57 -17
  125. package/lib/SyntheticAnimationEvent.js +39 -0
  126. package/lib/SyntheticClipboardEvent.js +2 -3
  127. package/lib/SyntheticCompositionEvent.js +2 -3
  128. package/lib/SyntheticDragEvent.js +2 -3
  129. package/lib/SyntheticEvent.js +97 -17
  130. package/lib/SyntheticFocusEvent.js +2 -3
  131. package/lib/SyntheticInputEvent.js +2 -3
  132. package/lib/SyntheticKeyboardEvent.js +2 -3
  133. package/lib/SyntheticMouseEvent.js +2 -3
  134. package/lib/SyntheticTouchEvent.js +2 -3
  135. package/lib/SyntheticTransitionEvent.js +39 -0
  136. package/lib/SyntheticUIEvent.js +2 -3
  137. package/lib/SyntheticWheelEvent.js +2 -3
  138. package/lib/TapEventPlugin.js +3 -12
  139. package/lib/Transaction.js +3 -3
  140. package/lib/ViewportMetrics.js +1 -1
  141. package/lib/accumulate.js +2 -2
  142. package/lib/accumulateInto.js +2 -2
  143. package/lib/adler32.js +3 -2
  144. package/lib/canDefineProperty.js +1 -1
  145. package/lib/createHierarchyRenderer.js +1 -1
  146. package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
  147. package/lib/dangerousStyleValue.js +25 -3
  148. package/lib/deprecated.js +4 -2
  149. package/lib/escapeTextContentForBrowser.js +1 -1
  150. package/lib/findDOMNode.js +15 -8
  151. package/lib/flattenChildren.js +2 -2
  152. package/lib/forEachAccumulated.js +2 -1
  153. package/lib/getEventCharCode.js +2 -2
  154. package/lib/getEventKey.js +1 -2
  155. package/lib/getEventModifierState.js +1 -2
  156. package/lib/getEventTarget.js +8 -2
  157. package/lib/getIteratorFn.js +2 -2
  158. package/lib/getNativeComponentFromComposite.js +30 -0
  159. package/lib/getNodeForCharacterOffset.js +2 -1
  160. package/lib/getTestDocument.js +1 -1
  161. package/lib/getTextContentAccessor.js +1 -1
  162. package/lib/getVendorPrefixedEventName.js +101 -0
  163. package/lib/instantiateReactComponent.js +9 -11
  164. package/lib/isEventSupported.js +2 -2
  165. package/lib/isTextInputElement.js +2 -1
  166. package/lib/onlyChild.js +2 -2
  167. package/lib/quoteAttributeValueForBrowser.js +1 -1
  168. package/lib/reactComponentExpect.js +2 -2
  169. package/lib/renderSubtreeIntoContainer.js +1 -1
  170. package/lib/setInnerHTML.js +5 -14
  171. package/lib/setTextContent.js +1 -1
  172. package/lib/shallowCompare.js +1 -1
  173. package/lib/shouldUpdateReactComponent.js +2 -3
  174. package/lib/sliceChildren.js +1 -1
  175. package/lib/traverseAllChildren.js +8 -8
  176. package/lib/update.js +12 -12
  177. package/lib/validateDOMNesting.js +15 -11
  178. package/package.json +2 -2
  179. package/lib/ReactBrowserComponentMixin.js +0 -36
  180. package/lib/ReactEmptyComponentRegistry.js +0 -48
  181. package/lib/ReactRootIndex.js +0 -29
  182. package/lib/ServerReactRootIndex.js +0 -29
  183. package/lib/cloneWithProps.js +0 -54
  184. package/lib/webcomponents.js +0 -6379
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014-2015, Facebook, Inc.
2
+ * Copyright 2014-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -68,7 +68,7 @@ function validateExplicitKey(element, parentType) {
68
68
  // we already showed the warning
69
69
  return;
70
70
  }
71
- 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;
71
+ 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 || '') : void 0;
72
72
  }
73
73
 
74
74
  /**
@@ -174,19 +174,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
174
174
  try {
175
175
  // This is intentionally an invariant that gets caught. It's the same
176
176
  // behavior as without this statement except with a better message.
177
- !(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;
177
+ !(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) : void 0;
178
178
  error = propTypes[propName](props, propName, componentName, location);
179
179
  } catch (ex) {
180
180
  error = ex;
181
181
  }
182
- 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;
182
+ 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) : void 0;
183
183
  if (error instanceof Error && !(error.message in loggedTypeFailures)) {
184
184
  // Only monitor this failure once because there tends to be a lot of the
185
185
  // same error.
186
186
  loggedTypeFailures[error.message] = true;
187
187
 
188
188
  var addendum = getDeclarationErrorAddendum();
189
- process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
189
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : void 0;
190
190
  }
191
191
  }
192
192
  }
@@ -208,7 +208,7 @@ function validatePropTypes(element) {
208
208
  checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
209
209
  }
210
210
  if (typeof componentClass.getDefaultProps === 'function') {
211
- 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;
211
+ 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.') : void 0;
212
212
  }
213
213
  }
214
214
 
@@ -218,7 +218,7 @@ var ReactElementValidator = {
218
218
  var validType = typeof type === 'string' || typeof type === 'function';
219
219
  // We warn in this case but don't throw. We expect the element creation to
220
220
  // succeed and there will likely be errors in render.
221
- process.env.NODE_ENV !== 'production' ? warning(validType, '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;
221
+ process.env.NODE_ENV !== 'production' ? warning(validType, '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()) : void 0;
222
222
 
223
223
  var element = ReactElement.createElement.apply(this, arguments);
224
224
 
@@ -254,7 +254,7 @@ var ReactElementValidator = {
254
254
  Object.defineProperty(validatedFactory, 'type', {
255
255
  enumerable: false,
256
256
  get: function () {
257
- process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
257
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : void 0;
258
258
  Object.defineProperty(this, 'type', {
259
259
  value: type
260
260
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014-2015, Facebook, Inc.
2
+ * Copyright 2014-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -11,44 +11,19 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactElement = require('./ReactElement');
15
- var ReactEmptyComponentRegistry = require('./ReactEmptyComponentRegistry');
16
- var ReactReconciler = require('./ReactReconciler');
17
-
18
- var assign = require('./Object.assign');
19
-
20
- var placeholderElement;
14
+ var emptyComponentFactory;
21
15
 
22
16
  var ReactEmptyComponentInjection = {
23
- injectEmptyComponent: function (component) {
24
- placeholderElement = ReactElement.createElement(component);
17
+ injectEmptyComponentFactory: function (factory) {
18
+ emptyComponentFactory = factory;
25
19
  }
26
20
  };
27
21
 
28
- function registerNullComponentID() {
29
- ReactEmptyComponentRegistry.registerNullComponentID(this._rootNodeID);
30
- }
31
-
32
- var ReactEmptyComponent = function (instantiate) {
33
- this._currentElement = null;
34
- this._rootNodeID = null;
35
- this._renderedComponent = instantiate(placeholderElement);
36
- };
37
- assign(ReactEmptyComponent.prototype, {
38
- construct: function (element) {},
39
- mountComponent: function (rootID, transaction, context) {
40
- transaction.getReactMountReady().enqueue(registerNullComponentID, this);
41
- this._rootNodeID = rootID;
42
- return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context);
43
- },
44
- receiveComponent: function () {},
45
- unmountComponent: function (rootID, transaction, context) {
46
- ReactReconciler.unmountComponent(this._renderedComponent);
47
- ReactEmptyComponentRegistry.deregisterNullComponentID(this._rootNodeID);
48
- this._rootNodeID = null;
49
- this._renderedComponent = null;
22
+ var ReactEmptyComponent = {
23
+ create: function (instantiate) {
24
+ return emptyComponentFactory(instantiate);
50
25
  }
51
- });
26
+ };
52
27
 
53
28
  ReactEmptyComponent.injection = ReactEmptyComponentInjection;
54
29
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,7 +7,6 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactErrorUtils
10
- * @typechecks
11
10
  */
12
11
 
13
12
  'use strict';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -23,14 +23,9 @@ var ReactEventEmitterMixin = {
23
23
  /**
24
24
  * Streams a fired top-level event to `EventPluginHub` where plugins have the
25
25
  * opportunity to create `ReactEvent`s to be dispatched.
26
- *
27
- * @param {string} topLevelType Record from `EventConstants`.
28
- * @param {object} topLevelTarget The listening component root node.
29
- * @param {string} topLevelTargetID ID of `topLevelTarget`.
30
- * @param {object} nativeEvent Native environment event.
31
26
  */
32
- handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
33
- var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
27
+ handleTopLevel: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
28
+ var events = EventPluginHub.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
34
29
  runEventQueueInBatch(events);
35
30
  }
36
31
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,7 +7,6 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactEventListener
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
@@ -15,32 +14,28 @@
15
14
  var EventListener = require('fbjs/lib/EventListener');
16
15
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
17
16
  var PooledClass = require('./PooledClass');
18
- var ReactInstanceHandles = require('./ReactInstanceHandles');
19
- var ReactMount = require('./ReactMount');
17
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
20
18
  var ReactUpdates = require('./ReactUpdates');
21
19
 
22
20
  var assign = require('./Object.assign');
23
21
  var getEventTarget = require('./getEventTarget');
24
22
  var getUnboundedScrollPosition = require('fbjs/lib/getUnboundedScrollPosition');
25
23
 
26
- var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
27
-
28
24
  /**
29
- * Finds the parent React component of `node`.
30
- *
31
- * @param {*} node
32
- * @return {?DOMEventTarget} Parent container, or `null` if the specified node
33
- * is not nested.
25
+ * Find the deepest React component completely containing the root of the
26
+ * passed-in instance (for use when entire React trees are nested within each
27
+ * other). If React trees are not nested, returns null.
34
28
  */
35
- function findParent(node) {
29
+ function findParent(inst) {
36
30
  // TODO: It may be a good idea to cache this to prevent unnecessary DOM
37
31
  // traversal, but caching is difficult to do correctly without using a
38
32
  // mutation observer to listen for all DOM changes.
39
- var nodeID = ReactMount.getID(node);
40
- var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
41
- var container = ReactMount.findReactContainerForID(rootID);
42
- var parent = ReactMount.getFirstReactDOM(container);
43
- return parent;
33
+ while (inst._nativeParent) {
34
+ inst = inst._nativeParent;
35
+ }
36
+ var rootNode = ReactDOMComponentTree.getNodeFromInstance(inst);
37
+ var container = rootNode.parentNode;
38
+ return ReactDOMComponentTree.getClosestInstanceFromNode(container);
44
39
  }
45
40
 
46
41
  // Used to store ancestor hierarchy in top level callback
@@ -59,72 +54,22 @@ assign(TopLevelCallbackBookKeeping.prototype, {
59
54
  PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
60
55
 
61
56
  function handleTopLevelImpl(bookKeeping) {
62
- // TODO: Re-enable event.path handling
63
- //
64
- // if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
65
- // // New browsers have a path attribute on native events
66
- // handleTopLevelWithPath(bookKeeping);
67
- // } else {
68
- // // Legacy browsers don't have a path attribute on native events
69
- // handleTopLevelWithoutPath(bookKeeping);
70
- // }
71
-
72
- void handleTopLevelWithPath; // temporarily unused
73
- handleTopLevelWithoutPath(bookKeeping);
74
- }
75
-
76
- // Legacy browsers don't have a path attribute on native events
77
- function handleTopLevelWithoutPath(bookKeeping) {
78
- var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
57
+ var nativeEventTarget = getEventTarget(bookKeeping.nativeEvent);
58
+ var targetInst = ReactDOMComponentTree.getClosestInstanceFromNode(nativeEventTarget);
79
59
 
80
60
  // Loop through the hierarchy, in case there's any nested components.
81
61
  // It's important that we build the array of ancestors before calling any
82
62
  // event handlers, because event handlers can modify the DOM, leading to
83
63
  // inconsistencies with ReactMount's node cache. See #1105.
84
- var ancestor = topLevelTarget;
85
- while (ancestor) {
64
+ var ancestor = targetInst;
65
+ do {
86
66
  bookKeeping.ancestors.push(ancestor);
87
- ancestor = findParent(ancestor);
88
- }
67
+ ancestor = ancestor && findParent(ancestor);
68
+ } while (ancestor);
89
69
 
90
70
  for (var i = 0; i < bookKeeping.ancestors.length; i++) {
91
- topLevelTarget = bookKeeping.ancestors[i];
92
- var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
93
- ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
94
- }
95
- }
96
-
97
- // New browsers have a path attribute on native events
98
- function handleTopLevelWithPath(bookKeeping) {
99
- var path = bookKeeping.nativeEvent.path;
100
- var currentNativeTarget = path[0];
101
- var eventsFired = 0;
102
- for (var i = 0; i < path.length; i++) {
103
- var currentPathElement = path[i];
104
- if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
105
- currentNativeTarget = path[i + 1];
106
- }
107
- // TODO: slow
108
- var reactParent = ReactMount.getFirstReactDOM(currentPathElement);
109
- if (reactParent === currentPathElement) {
110
- var currentPathElementID = ReactMount.getID(currentPathElement);
111
- var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID);
112
- bookKeeping.ancestors.push(currentPathElement);
113
-
114
- var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
115
- eventsFired++;
116
- ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
117
-
118
- // Jump to the root of this React render tree
119
- while (currentPathElementID !== newRootID) {
120
- i++;
121
- currentPathElement = path[i];
122
- currentPathElementID = ReactMount.getID(currentPathElement);
123
- }
124
- }
125
- }
126
- if (eventsFired === 0) {
127
- ReactEventListener._handleTopLevel(bookKeeping.topLevelType, window, '', bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
71
+ targetInst = bookKeeping.ancestors[i];
72
+ ReactEventListener._handleTopLevel(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
128
73
  }
129
74
  }
130
75
 
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright 2013-present, 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 ReactFeatureFlags
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactFeatureFlags = {
15
+ // When true, call console.time() before and .timeEnd() after each top-level
16
+ // render (both initial renders and updates). Useful when looking at prod-mode
17
+ // timeline profiles in Chrome, for example.
18
+ logTopLevelRenders: false
19
+ };
20
+
21
+ module.exports = ReactFeatureFlags;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2015, Facebook, Inc.
2
+ * Copyright 2015-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -20,7 +20,7 @@ var warning = require('fbjs/lib/warning');
20
20
 
21
21
  /**
22
22
  * We used to allow keyed objects to serve as a collection of ReactElements,
23
- * or nested sets. This allowed us a way to explicitly key a set a fragment of
23
+ * or nested sets. This allowed us a way to explicitly key a set or fragment of
24
24
  * components. This is now being replaced with an opaque data structure.
25
25
  * The upgrade path is to call React.addons.createFragment({ key: value }) to
26
26
  * create a keyed fragment. The resulting data structure is an array.
@@ -35,22 +35,22 @@ var ReactFragment = {
35
35
  // of its properties.
36
36
  create: function (object) {
37
37
  if (typeof object !== 'object' || !object || Array.isArray(object)) {
38
- process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : undefined;
38
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : void 0;
39
39
  return object;
40
40
  }
41
41
  if (ReactElement.isValidElement(object)) {
42
- process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : undefined;
42
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : void 0;
43
43
  return object;
44
44
  }
45
45
 
46
- !(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) : undefined;
46
+ !(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) : void 0;
47
47
 
48
48
  var result = [];
49
49
 
50
50
  for (var key in object) {
51
51
  if (process.env.NODE_ENV !== 'production') {
52
52
  if (!warnedAboutNumeric && numericPropertyRegex.test(key)) {
53
- process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') : undefined;
53
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') : void 0;
54
54
  warnedAboutNumeric = true;
55
55
  }
56
56
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -13,13 +13,13 @@
13
13
 
14
14
  var DOMProperty = require('./DOMProperty');
15
15
  var EventPluginHub = require('./EventPluginHub');
16
+ var EventPluginUtils = require('./EventPluginUtils');
16
17
  var ReactComponentEnvironment = require('./ReactComponentEnvironment');
17
18
  var ReactClass = require('./ReactClass');
18
19
  var ReactEmptyComponent = require('./ReactEmptyComponent');
19
20
  var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
20
21
  var ReactNativeComponent = require('./ReactNativeComponent');
21
22
  var ReactPerf = require('./ReactPerf');
22
- var ReactRootIndex = require('./ReactRootIndex');
23
23
  var ReactUpdates = require('./ReactUpdates');
24
24
 
25
25
  var ReactInjection = {
@@ -28,10 +28,10 @@ var ReactInjection = {
28
28
  DOMProperty: DOMProperty.injection,
29
29
  EmptyComponent: ReactEmptyComponent.injection,
30
30
  EventPluginHub: EventPluginHub.injection,
31
+ EventPluginUtils: EventPluginUtils.injection,
31
32
  EventEmitter: ReactBrowserEventEmitter.injection,
32
33
  NativeComponent: ReactNativeComponent.injection,
33
34
  Perf: ReactPerf.injection,
34
- RootIndex: ReactRootIndex.injection,
35
35
  Updates: ReactUpdates.injection
36
36
  };
37
37
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -74,7 +74,7 @@ var ReactInputSelection = {
74
74
  start: input.selectionStart,
75
75
  end: input.selectionEnd
76
76
  };
77
- } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
77
+ } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
78
78
  // IE8 input.
79
79
  var range = document.selection.createRange();
80
80
  // There can only be one selection per document in IE, so it must
@@ -102,14 +102,14 @@ var ReactInputSelection = {
102
102
  setSelection: function (input, offsets) {
103
103
  var start = offsets.start;
104
104
  var end = offsets.end;
105
- if (typeof end === 'undefined') {
105
+ if (end === undefined) {
106
106
  end = start;
107
107
  }
108
108
 
109
109
  if ('selectionStart' in input) {
110
110
  input.selectionStart = start;
111
111
  input.selectionEnd = Math.min(end, input.value.length);
112
- } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
112
+ } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
113
113
  var range = input.createTextRange();
114
114
  range.collapse(true);
115
115
  range.moveStart('character', start);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,13 +7,10 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactInstanceHandles
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
15
- var ReactRootIndex = require('./ReactRootIndex');
16
-
17
14
  var invariant = require('fbjs/lib/invariant');
18
15
 
19
16
  var SEPARATOR = '.';
@@ -91,8 +88,8 @@ function getParentID(id) {
91
88
  * @private
92
89
  */
93
90
  function getNextDescendantID(ancestorID, destinationID) {
94
- !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined;
95
- !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined;
91
+ !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : void 0;
92
+ !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : void 0;
96
93
  if (ancestorID === destinationID) {
97
94
  return ancestorID;
98
95
  }
@@ -134,7 +131,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
134
131
  }
135
132
  }
136
133
  var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
137
- !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined;
134
+ !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : void 0;
138
135
  return longestCommonID;
139
136
  }
140
137
 
@@ -154,9 +151,9 @@ function getFirstCommonAncestorID(oneID, twoID) {
154
151
  function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
155
152
  start = start || '';
156
153
  stop = stop || '';
157
- !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
154
+ !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : void 0;
158
155
  var traverseUp = isAncestorIDOf(stop, start);
159
- !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined;
156
+ !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : void 0;
160
157
  // Traverse from `start` to `stop` one depth at a time.
161
158
  var depth = 0;
162
159
  var traverse = traverseUp ? getParentID : getNextDescendantID;
@@ -169,7 +166,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
169
166
  // Only break //after// visiting `stop`.
170
167
  break;
171
168
  }
172
- !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : undefined;
169
+ !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : void 0;
173
170
  }
174
171
  }
175
172
 
@@ -184,10 +181,11 @@ var ReactInstanceHandles = {
184
181
 
185
182
  /**
186
183
  * Constructs a React root ID
184
+ * @param {number} index A unique integer
187
185
  * @return {string} A React root ID.
188
186
  */
189
- createReactRootID: function () {
190
- return getReactRootIDString(ReactRootIndex.createReactRootIndex());
187
+ createReactRootID: function (index) {
188
+ return getReactRootIDString(index);
191
189
  },
192
190
 
193
191
  /**