react 0.14.7 → 0.15.0-alpha.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 (177) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +2937 -3414
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +2762 -3034
  5. package/dist/react.min.js +7 -7
  6. package/lib/AutoFocusUtils.js +3 -15
  7. package/lib/BeforeInputEventPlugin.js +8 -25
  8. package/lib/CSSProperty.js +3 -1
  9. package/lib/CSSPropertyOperations.js +20 -6
  10. package/lib/CallbackQueue.js +12 -1
  11. package/lib/ChangeEventPlugin.js +58 -54
  12. package/lib/DOMChildrenOperations.js +21 -60
  13. package/lib/DOMLazyTree.js +95 -0
  14. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  15. package/lib/DOMProperty.js +7 -2
  16. package/lib/DOMPropertyOperations.js +66 -36
  17. package/lib/Danger.js +6 -7
  18. package/lib/DefaultEventPluginOrder.js +1 -1
  19. package/lib/EnterLeaveEventPlugin.js +24 -43
  20. package/lib/EventConstants.js +2 -1
  21. package/lib/EventPluginHub.js +15 -59
  22. package/lib/EventPluginRegistry.js +23 -2
  23. package/lib/EventPluginUtils.js +60 -35
  24. package/lib/EventPropagators.js +19 -17
  25. package/lib/FallbackCompositionState.js +1 -2
  26. package/lib/HTMLDOMPropertyConfig.js +21 -23
  27. package/lib/LinkedInput.js +49 -0
  28. package/lib/LinkedStateMixin.js +1 -2
  29. package/lib/LinkedValueUtils.js +1 -2
  30. package/lib/MetaMatchers.js +2 -2
  31. package/lib/Object.assign.js +1 -1
  32. package/lib/OrderedMap.js +1 -1
  33. package/lib/PooledClass.js +1 -1
  34. package/lib/React.js +1 -13
  35. package/lib/ReactBrowserEventEmitter.js +3 -23
  36. package/lib/ReactCSSTransitionGroup.js +1 -2
  37. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  38. package/lib/ReactChildReconciler.js +12 -10
  39. package/lib/ReactChildren.js +3 -3
  40. package/lib/ReactClass.js +18 -67
  41. package/lib/ReactComponent.js +2 -5
  42. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  43. package/lib/ReactComponentEnvironment.js +3 -3
  44. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  45. package/lib/ReactCompositeComponent.js +94 -29
  46. package/lib/ReactCurrentOwner.js +1 -1
  47. package/lib/ReactDOM.js +26 -14
  48. package/lib/ReactDOMButton.js +2 -2
  49. package/lib/ReactDOMComponent.js +156 -218
  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 +61 -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 +52 -23
  59. package/lib/ReactDOMInstrumentation.js +16 -0
  60. package/lib/ReactDOMOption.js +9 -8
  61. package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +57 -0
  62. package/lib/ReactDOMSelect.js +35 -14
  63. package/lib/ReactDOMSelection.js +2 -2
  64. package/lib/ReactDOMServer.js +1 -1
  65. package/lib/ReactDOMTextComponent.js +41 -21
  66. package/lib/ReactDOMTextarea.js +32 -5
  67. package/lib/ReactDOMTreeTraversal.js +134 -0
  68. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  69. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  70. package/lib/ReactDefaultInjection.js +11 -15
  71. package/lib/ReactDefaultPerf.js +49 -19
  72. package/lib/ReactDefaultPerfAnalysis.js +16 -9
  73. package/lib/ReactElement.js +9 -5
  74. package/lib/ReactElementValidator.js +1 -1
  75. package/lib/ReactEmptyComponent.js +8 -29
  76. package/lib/ReactErrorUtils.js +1 -2
  77. package/lib/ReactEventEmitterMixin.js +3 -8
  78. package/lib/ReactEventListener.js +20 -75
  79. package/lib/ReactFeatureFlags.js +21 -0
  80. package/lib/ReactFragment.js +2 -2
  81. package/lib/ReactInjection.js +3 -3
  82. package/lib/ReactInputSelection.js +3 -3
  83. package/lib/ReactInstanceHandles.js +4 -6
  84. package/lib/ReactInstanceMap.js +1 -1
  85. package/lib/ReactIsomorphic.js +1 -1
  86. package/lib/ReactLink.js +1 -2
  87. package/lib/ReactMarkupChecksum.js +1 -1
  88. package/lib/ReactMount.js +67 -445
  89. package/lib/ReactMultiChild.js +104 -198
  90. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  91. package/lib/ReactNativeComponent.js +1 -1
  92. package/lib/ReactNodeTypes.js +37 -0
  93. package/lib/ReactNoopUpdateQueue.js +1 -24
  94. package/lib/ReactOwner.js +1 -1
  95. package/lib/ReactPerf.js +1 -2
  96. package/lib/ReactPropTransferer.js +1 -1
  97. package/lib/ReactPropTypeLocationNames.js +1 -1
  98. package/lib/ReactPropTypeLocations.js +1 -1
  99. package/lib/ReactPropTypes.js +8 -2
  100. package/lib/ReactReconcileTransaction.js +17 -6
  101. package/lib/ReactReconciler.js +14 -5
  102. package/lib/ReactRef.js +1 -1
  103. package/lib/ReactServerBatchingStrategy.js +1 -2
  104. package/lib/ReactServerRendering.js +15 -33
  105. package/lib/ReactServerRenderingTransaction.js +8 -26
  106. package/lib/ReactSimpleEmptyComponent.js +37 -0
  107. package/lib/ReactStateSetters.js +1 -1
  108. package/lib/ReactTestUtils.js +25 -15
  109. package/lib/ReactTransitionChildMapping.js +1 -2
  110. package/lib/ReactTransitionEvents.js +1 -1
  111. package/lib/ReactTransitionGroup.js +1 -1
  112. package/lib/ReactUpdateQueue.js +4 -4
  113. package/lib/ReactUpdates.js +19 -2
  114. package/lib/ReactVersion.js +2 -2
  115. package/lib/ReactWithAddons.js +1 -3
  116. package/lib/ResponderEventPlugin.js +53 -65
  117. package/lib/ResponderSyntheticEvent.js +1 -2
  118. package/lib/ResponderTouchHistoryStore.js +1 -1
  119. package/lib/SVGDOMPropertyConfig.js +2 -39
  120. package/lib/SelectEventPlugin.js +13 -18
  121. package/lib/SimpleEventPlugin.js +18 -16
  122. package/lib/SyntheticClipboardEvent.js +1 -2
  123. package/lib/SyntheticCompositionEvent.js +1 -2
  124. package/lib/SyntheticDragEvent.js +1 -2
  125. package/lib/SyntheticEvent.js +10 -7
  126. package/lib/SyntheticFocusEvent.js +1 -2
  127. package/lib/SyntheticInputEvent.js +1 -2
  128. package/lib/SyntheticKeyboardEvent.js +1 -2
  129. package/lib/SyntheticMouseEvent.js +1 -2
  130. package/lib/SyntheticTouchEvent.js +1 -2
  131. package/lib/SyntheticUIEvent.js +1 -2
  132. package/lib/SyntheticWheelEvent.js +1 -2
  133. package/lib/TapEventPlugin.js +3 -12
  134. package/lib/Transaction.js +1 -1
  135. package/lib/ViewportMetrics.js +1 -1
  136. package/lib/accumulate.js +1 -1
  137. package/lib/accumulateInto.js +1 -1
  138. package/lib/adler32.js +3 -2
  139. package/lib/canDefineProperty.js +1 -1
  140. package/lib/createHierarchyRenderer.js +1 -1
  141. package/lib/dangerousStyleValue.js +25 -3
  142. package/lib/deprecated.js +1 -1
  143. package/lib/escapeTextContentForBrowser.js +1 -1
  144. package/lib/findDOMNode.js +15 -8
  145. package/lib/flattenChildren.js +1 -1
  146. package/lib/forEachAccumulated.js +1 -1
  147. package/lib/getEventCharCode.js +1 -2
  148. package/lib/getEventKey.js +1 -2
  149. package/lib/getEventModifierState.js +1 -2
  150. package/lib/getEventTarget.js +1 -2
  151. package/lib/getIteratorFn.js +1 -2
  152. package/lib/getNativeComponentFromComposite.js +30 -0
  153. package/lib/getNodeForCharacterOffset.js +1 -1
  154. package/lib/getTestDocument.js +1 -1
  155. package/lib/getTextContentAccessor.js +1 -1
  156. package/lib/instantiateReactComponent.js +3 -4
  157. package/lib/isEventSupported.js +1 -1
  158. package/lib/isTextInputElement.js +1 -1
  159. package/lib/onlyChild.js +1 -1
  160. package/lib/quoteAttributeValueForBrowser.js +1 -1
  161. package/lib/reactComponentExpect.js +1 -1
  162. package/lib/renderSubtreeIntoContainer.js +1 -1
  163. package/lib/setInnerHTML.js +1 -1
  164. package/lib/setTextContent.js +1 -1
  165. package/lib/shallowCompare.js +1 -1
  166. package/lib/shouldUpdateReactComponent.js +1 -3
  167. package/lib/sliceChildren.js +1 -1
  168. package/lib/traverseAllChildren.js +6 -6
  169. package/lib/update.js +1 -1
  170. package/lib/validateDOMNesting.js +8 -9
  171. package/package.json +2 -2
  172. package/lib/ReactBrowserComponentMixin.js +0 -36
  173. package/lib/ReactEmptyComponentRegistry.js +0 -48
  174. package/lib/ReactRootIndex.js +0 -29
  175. package/lib/ServerReactRootIndex.js +0 -29
  176. package/lib/cloneWithProps.js +0 -54
  177. package/lib/webcomponents.js +0 -6379
package/lib/Danger.js CHANGED
@@ -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,11 +7,11 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule Danger
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
14
+ var DOMLazyTree = require('./DOMLazyTree');
15
15
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
16
16
 
17
17
  var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
@@ -129,15 +129,14 @@ var Danger = {
129
129
  dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
130
130
  !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' + 'worker thread. Make sure `window` and `document` are available ' + 'globally before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
131
131
  !markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
132
- !(oldChild.tagName.toLowerCase() !== 'html') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' + '<html> node. This is because browser quirks make this unreliable ' + 'and/or slow. If you want to render to the root you must use ' + 'server rendering. See ReactDOMServer.renderToString().') : invariant(false) : undefined;
132
+ !(oldChild.nodeName !== 'HTML') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' + '<html> node. This is because browser quirks make this unreliable ' + 'and/or slow. If you want to render to the root you must use ' + 'server rendering. See ReactDOMServer.renderToString().') : invariant(false) : undefined;
133
133
 
134
- var newChild;
135
134
  if (typeof markup === 'string') {
136
- newChild = createNodesFromMarkup(markup, emptyFunction)[0];
135
+ var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
136
+ oldChild.parentNode.replaceChild(newChild, oldChild);
137
137
  } else {
138
- newChild = markup;
138
+ DOMLazyTree.replaceChildWithTree(oldChild, markup);
139
139
  }
140
- oldChild.parentNode.replaceChild(newChild, oldChild);
141
140
  }
142
141
 
143
142
  };
@@ -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
@@ -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,20 +7,18 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule EnterLeaveEventPlugin
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
15
14
  var EventConstants = require('./EventConstants');
16
15
  var EventPropagators = require('./EventPropagators');
16
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
17
17
  var SyntheticMouseEvent = require('./SyntheticMouseEvent');
18
18
 
19
- var ReactMount = require('./ReactMount');
20
19
  var keyOf = require('fbjs/lib/keyOf');
21
20
 
22
21
  var topLevelTypes = EventConstants.topLevelTypes;
23
- var getFirstReactDOM = ReactMount.getFirstReactDOM;
24
22
 
25
23
  var eventTypes = {
26
24
  mouseEnter: {
@@ -33,8 +31,6 @@ var eventTypes = {
33
31
  }
34
32
  };
35
33
 
36
- var extractedEvents = [null, null];
37
-
38
34
  var EnterLeaveEventPlugin = {
39
35
 
40
36
  eventTypes: eventTypes,
@@ -45,15 +41,8 @@ var EnterLeaveEventPlugin = {
45
41
  * we do not extract duplicate events. However, moving the mouse into the
46
42
  * browser from outside will not fire a `mouseout` event. In this case, we use
47
43
  * the `mouseover` top-level event.
48
- *
49
- * @param {string} topLevelType Record from `EventConstants`.
50
- * @param {DOMEventTarget} topLevelTarget The listening component root node.
51
- * @param {string} topLevelTargetID ID of `topLevelTarget`.
52
- * @param {object} nativeEvent Native browser event.
53
- * @return {*} An accumulation of synthetic events.
54
- * @see {EventPluginHub.extractEvents}
55
44
  */
56
- extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
45
+ extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
57
46
  if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
58
47
  return null;
59
48
  }
@@ -63,12 +52,12 @@ var EnterLeaveEventPlugin = {
63
52
  }
64
53
 
65
54
  var win;
66
- if (topLevelTarget.window === topLevelTarget) {
67
- // `topLevelTarget` is probably a window object.
68
- win = topLevelTarget;
55
+ if (nativeEventTarget.window === nativeEventTarget) {
56
+ // `nativeEventTarget` is probably a window object.
57
+ win = nativeEventTarget;
69
58
  } else {
70
59
  // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
71
- var doc = topLevelTarget.ownerDocument;
60
+ var doc = nativeEventTarget.ownerDocument;
72
61
  if (doc) {
73
62
  win = doc.defaultView || doc.parentWindow;
74
63
  } else {
@@ -78,22 +67,14 @@ var EnterLeaveEventPlugin = {
78
67
 
79
68
  var from;
80
69
  var to;
81
- var fromID = '';
82
- var toID = '';
83
70
  if (topLevelType === topLevelTypes.topMouseOut) {
84
- from = topLevelTarget;
85
- fromID = topLevelTargetID;
86
- to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement);
87
- if (to) {
88
- toID = ReactMount.getID(to);
89
- } else {
90
- to = win;
91
- }
92
- to = to || win;
71
+ from = targetInst;
72
+ var related = nativeEvent.relatedTarget || nativeEvent.toElement;
73
+ to = related ? ReactDOMComponentTree.getClosestInstanceFromNode(related) : null;
93
74
  } else {
94
- from = win;
95
- to = topLevelTarget;
96
- toID = topLevelTargetID;
75
+ // Moving to a node from outside the window.
76
+ from = null;
77
+ to = targetInst;
97
78
  }
98
79
 
99
80
  if (from === to) {
@@ -101,22 +82,22 @@ var EnterLeaveEventPlugin = {
101
82
  return null;
102
83
  }
103
84
 
104
- var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget);
85
+ var fromNode = from == null ? win : ReactDOMComponentTree.getNodeFromInstance(from);
86
+ var toNode = to == null ? win : ReactDOMComponentTree.getNodeFromInstance(to);
87
+
88
+ var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, from, nativeEvent, nativeEventTarget);
105
89
  leave.type = 'mouseleave';
106
- leave.target = from;
107
- leave.relatedTarget = to;
90
+ leave.target = fromNode;
91
+ leave.relatedTarget = toNode;
108
92
 
109
- var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, toID, nativeEvent, nativeEventTarget);
93
+ var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, to, nativeEvent, nativeEventTarget);
110
94
  enter.type = 'mouseenter';
111
- enter.target = to;
112
- enter.relatedTarget = from;
113
-
114
- EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
95
+ enter.target = toNode;
96
+ enter.relatedTarget = fromNode;
115
97
 
116
- extractedEvents[0] = leave;
117
- extractedEvents[1] = enter;
98
+ EventPropagators.accumulateEnterLeaveDispatches(leave, enter, from, to);
118
99
 
119
- return extractedEvents;
100
+ return [leave, enter];
120
101
  }
121
102
 
122
103
  };
@@ -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
@@ -47,6 +47,7 @@ var topLevelTypes = keyMirror({
47
47
  topError: null,
48
48
  topFocus: null,
49
49
  topInput: null,
50
+ topInvalid: null,
50
51
  topKeyDown: null,
51
52
  topKeyPress: null,
52
53
  topKeyUp: null,
@@ -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
@@ -18,7 +18,6 @@ var ReactErrorUtils = require('./ReactErrorUtils');
18
18
  var accumulateInto = require('./accumulateInto');
19
19
  var forEachAccumulated = require('./forEachAccumulated');
20
20
  var invariant = require('fbjs/lib/invariant');
21
- var warning = require('fbjs/lib/warning');
22
21
 
23
22
  /**
24
23
  * Internal store for event listeners
@@ -54,17 +53,6 @@ var executeDispatchesAndReleaseTopLevel = function (e) {
54
53
  return executeDispatchesAndRelease(e, false);
55
54
  };
56
55
 
57
- /**
58
- * - `InstanceHandle`: [required] Module that performs logical traversals of DOM
59
- * hierarchy given ids of the logical DOM elements involved.
60
- */
61
- var InstanceHandle = null;
62
-
63
- function validateInstanceHandle() {
64
- var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
65
- process.env.NODE_ENV !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
66
- }
67
-
68
56
  /**
69
57
  * This is a unified interface for event plugins to be installed and configured.
70
58
  *
@@ -94,30 +82,6 @@ var EventPluginHub = {
94
82
  */
95
83
  injection: {
96
84
 
97
- /**
98
- * @param {object} InjectedMount
99
- * @public
100
- */
101
- injectMount: EventPluginUtils.injection.injectMount,
102
-
103
- /**
104
- * @param {object} InjectedInstanceHandle
105
- * @public
106
- */
107
- injectInstanceHandle: function (InjectedInstanceHandle) {
108
- InstanceHandle = InjectedInstanceHandle;
109
- if (process.env.NODE_ENV !== 'production') {
110
- validateInstanceHandle();
111
- }
112
- },
113
-
114
- getInstanceHandle: function () {
115
- if (process.env.NODE_ENV !== 'production') {
116
- validateInstanceHandle();
117
- }
118
- return InstanceHandle;
119
- },
120
-
121
85
  /**
122
86
  * @param {array} InjectedEventPluginOrder
123
87
  * @public
@@ -131,10 +95,6 @@ var EventPluginHub = {
131
95
 
132
96
  },
133
97
 
134
- eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
135
-
136
- registrationNameModules: EventPluginRegistry.registrationNameModules,
137
-
138
98
  /**
139
99
  * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
140
100
  *
@@ -142,15 +102,15 @@ var EventPluginHub = {
142
102
  * @param {string} registrationName Name of listener (e.g. `onClick`).
143
103
  * @param {?function} listener The callback to store.
144
104
  */
145
- putListener: function (id, registrationName, listener) {
105
+ putListener: function (inst, registrationName, listener) {
146
106
  !(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : undefined;
147
107
 
148
108
  var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
149
- bankForRegistrationName[id] = listener;
109
+ bankForRegistrationName[inst._rootNodeID] = listener;
150
110
 
151
111
  var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
152
112
  if (PluginModule && PluginModule.didPutListener) {
153
- PluginModule.didPutListener(id, registrationName, listener);
113
+ PluginModule.didPutListener(inst, registrationName, listener);
154
114
  }
155
115
  },
156
116
 
@@ -159,9 +119,9 @@ var EventPluginHub = {
159
119
  * @param {string} registrationName Name of listener (e.g. `onClick`).
160
120
  * @return {?function} The stored callback.
161
121
  */
162
- getListener: function (id, registrationName) {
122
+ getListener: function (inst, registrationName) {
163
123
  var bankForRegistrationName = listenerBank[registrationName];
164
- return bankForRegistrationName && bankForRegistrationName[id];
124
+ return bankForRegistrationName && bankForRegistrationName[inst._rootNodeID];
165
125
  },
166
126
 
167
127
  /**
@@ -170,16 +130,16 @@ var EventPluginHub = {
170
130
  * @param {string} id ID of the DOM element.
171
131
  * @param {string} registrationName Name of listener (e.g. `onClick`).
172
132
  */
173
- deleteListener: function (id, registrationName) {
133
+ deleteListener: function (inst, registrationName) {
174
134
  var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
175
135
  if (PluginModule && PluginModule.willDeleteListener) {
176
- PluginModule.willDeleteListener(id, registrationName);
136
+ PluginModule.willDeleteListener(inst, registrationName);
177
137
  }
178
138
 
179
139
  var bankForRegistrationName = listenerBank[registrationName];
180
140
  // TODO: This should never be null -- when is it?
181
141
  if (bankForRegistrationName) {
182
- delete bankForRegistrationName[id];
142
+ delete bankForRegistrationName[inst._rootNodeID];
183
143
  }
184
144
  },
185
145
 
@@ -188,18 +148,18 @@ var EventPluginHub = {
188
148
  *
189
149
  * @param {string} id ID of the DOM element.
190
150
  */
191
- deleteAllListeners: function (id) {
151
+ deleteAllListeners: function (inst) {
192
152
  for (var registrationName in listenerBank) {
193
- if (!listenerBank[registrationName][id]) {
153
+ if (!listenerBank[registrationName][inst._rootNodeID]) {
194
154
  continue;
195
155
  }
196
156
 
197
157
  var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
198
158
  if (PluginModule && PluginModule.willDeleteListener) {
199
- PluginModule.willDeleteListener(id, registrationName);
159
+ PluginModule.willDeleteListener(inst, registrationName);
200
160
  }
201
161
 
202
- delete listenerBank[registrationName][id];
162
+ delete listenerBank[registrationName][inst._rootNodeID];
203
163
  }
204
164
  },
205
165
 
@@ -207,21 +167,17 @@ var EventPluginHub = {
207
167
  * Allows registered plugins an opportunity to extract events from top-level
208
168
  * native browser events.
209
169
  *
210
- * @param {string} topLevelType Record from `EventConstants`.
211
- * @param {DOMEventTarget} topLevelTarget The listening component root node.
212
- * @param {string} topLevelTargetID ID of `topLevelTarget`.
213
- * @param {object} nativeEvent Native browser event.
214
170
  * @return {*} An accumulation of synthetic events.
215
171
  * @internal
216
172
  */
217
- extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
173
+ extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
218
174
  var events;
219
175
  var plugins = EventPluginRegistry.plugins;
220
176
  for (var i = 0; i < plugins.length; i++) {
221
177
  // Not every plugin in the ordering may be loaded at runtime.
222
178
  var possiblePlugin = plugins[i];
223
179
  if (possiblePlugin) {
224
- var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
180
+ var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
225
181
  if (extractedEvents) {
226
182
  events = accumulateInto(events, extractedEvents);
227
183
  }
@@ -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 EventPluginRegistry
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
@@ -90,6 +89,11 @@ function publishRegistrationName(registrationName, PluginModule, eventName) {
90
89
  !!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
91
90
  EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
92
91
  EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
92
+
93
+ if (process.env.NODE_ENV !== 'production') {
94
+ var lowerCasedName = registrationName.toLowerCase();
95
+ EventPluginRegistry.possibleRegistrationNames[lowerCasedName] = registrationName;
96
+ }
93
97
  }
94
98
 
95
99
  /**
@@ -119,6 +123,14 @@ var EventPluginRegistry = {
119
123
  */
120
124
  registrationNameDependencies: {},
121
125
 
126
+ /**
127
+ * Mapping from lowercase registration names to the properly cased version,
128
+ * used to warn in the case of missing event handlers. Available
129
+ * only in __DEV__.
130
+ * @type {Object}
131
+ */
132
+ possibleRegistrationNames: process.env.NODE_ENV !== 'production' ? {} : null,
133
+
122
134
  /**
123
135
  * Injects an ordering of plugins (by plugin name). This allows the ordering
124
136
  * to be decoupled from injection of the actual plugins so that ordering is
@@ -213,6 +225,15 @@ var EventPluginRegistry = {
213
225
  delete registrationNameModules[registrationName];
214
226
  }
215
227
  }
228
+
229
+ if (process.env.NODE_ENV !== 'production') {
230
+ var possibleRegistrationNames = EventPluginRegistry.possibleRegistrationNames;
231
+ for (var lowerCasedName in possibleRegistrationNames) {
232
+ if (possibleRegistrationNames.hasOwnProperty(lowerCasedName)) {
233
+ delete possibleRegistrationNames[lowerCasedName];
234
+ }
235
+ }
236
+ }
216
237
  }
217
238
 
218
239
  };
@@ -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
@@ -22,15 +22,22 @@ var warning = require('fbjs/lib/warning');
22
22
  */
23
23
 
24
24
  /**
25
- * - `Mount`: [required] Module that can convert between React dom IDs and
26
- * actual node references.
25
+ * - `ComponentTree`: [required] Module that can convert between React instances
26
+ * and actual node references.
27
27
  */
28
+ var ComponentTree;
29
+ var TreeTraversal;
28
30
  var injection = {
29
- Mount: null,
30
- injectMount: function (InjectedMount) {
31
- injection.Mount = InjectedMount;
31
+ injectComponentTree: function (Injected) {
32
+ ComponentTree = Injected;
32
33
  if (process.env.NODE_ENV !== 'production') {
33
- process.env.NODE_ENV !== 'production' ? warning(InjectedMount && InjectedMount.getNode && InjectedMount.getID, 'EventPluginUtils.injection.injectMount(...): Injected Mount ' + 'module is missing getNode or getID.') : undefined;
34
+ process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : undefined;
35
+ }
36
+ },
37
+ injectTreeTraversal: function (Injected) {
38
+ TreeTraversal = Injected;
39
+ if (process.env.NODE_ENV !== 'production') {
40
+ process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.isAncestor && Injected.getLowestCommonAncestor, 'EventPluginUtils.injection.injectTreeTraversal(...): Injected ' + 'module is missing isAncestor or getLowestCommonAncestor.') : undefined;
34
41
  }
35
42
  }
36
43
  };
@@ -52,14 +59,15 @@ var validateEventDispatches;
52
59
  if (process.env.NODE_ENV !== 'production') {
53
60
  validateEventDispatches = function (event) {
54
61
  var dispatchListeners = event._dispatchListeners;
55
- var dispatchIDs = event._dispatchIDs;
62
+ var dispatchInstances = event._dispatchInstances;
56
63
 
57
64
  var listenersIsArr = Array.isArray(dispatchListeners);
58
- var idsIsArr = Array.isArray(dispatchIDs);
59
- var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
60
65
  var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
61
66
 
62
- process.env.NODE_ENV !== 'production' ? warning(idsIsArr === listenersIsArr && IDsLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined;
67
+ var instancesIsArr = Array.isArray(dispatchInstances);
68
+ var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
69
+
70
+ process.env.NODE_ENV !== 'production' ? warning(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined;
63
71
  };
64
72
  }
65
73
 
@@ -68,15 +76,15 @@ if (process.env.NODE_ENV !== 'production') {
68
76
  * @param {SyntheticEvent} event SyntheticEvent to handle
69
77
  * @param {boolean} simulated If the event is simulated (changes exn behavior)
70
78
  * @param {function} listener Application-level callback
71
- * @param {string} domID DOM id to pass to the callback.
79
+ * @param {*} inst Internal component instance
72
80
  */
73
- function executeDispatch(event, simulated, listener, domID) {
81
+ function executeDispatch(event, simulated, listener, inst) {
74
82
  var type = event.type || 'unknown-event';
75
- event.currentTarget = injection.Mount.getNode(domID);
83
+ event.currentTarget = EventPluginUtils.getNodeFromInstance(inst);
76
84
  if (simulated) {
77
- ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event, domID);
85
+ ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event);
78
86
  } else {
79
- ReactErrorUtils.invokeGuardedCallback(type, listener, event, domID);
87
+ ReactErrorUtils.invokeGuardedCallback(type, listener, event);
80
88
  }
81
89
  event.currentTarget = null;
82
90
  }
@@ -86,7 +94,7 @@ function executeDispatch(event, simulated, listener, domID) {
86
94
  */
87
95
  function executeDispatchesInOrder(event, simulated) {
88
96
  var dispatchListeners = event._dispatchListeners;
89
- var dispatchIDs = event._dispatchIDs;
97
+ var dispatchInstances = event._dispatchInstances;
90
98
  if (process.env.NODE_ENV !== 'production') {
91
99
  validateEventDispatches(event);
92
100
  }
@@ -95,14 +103,14 @@ function executeDispatchesInOrder(event, simulated) {
95
103
  if (event.isPropagationStopped()) {
96
104
  break;
97
105
  }
98
- // Listeners and IDs are two parallel arrays that are always in sync.
99
- executeDispatch(event, simulated, dispatchListeners[i], dispatchIDs[i]);
106
+ // Listeners and Instances are two parallel arrays that are always in sync.
107
+ executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]);
100
108
  }
101
109
  } else if (dispatchListeners) {
102
- executeDispatch(event, simulated, dispatchListeners, dispatchIDs);
110
+ executeDispatch(event, simulated, dispatchListeners, dispatchInstances);
103
111
  }
104
112
  event._dispatchListeners = null;
105
- event._dispatchIDs = null;
113
+ event._dispatchInstances = null;
106
114
  }
107
115
 
108
116
  /**
@@ -114,7 +122,7 @@ function executeDispatchesInOrder(event, simulated) {
114
122
  */
115
123
  function executeDispatchesInOrderStopAtTrueImpl(event) {
116
124
  var dispatchListeners = event._dispatchListeners;
117
- var dispatchIDs = event._dispatchIDs;
125
+ var dispatchInstances = event._dispatchInstances;
118
126
  if (process.env.NODE_ENV !== 'production') {
119
127
  validateEventDispatches(event);
120
128
  }
@@ -123,14 +131,14 @@ function executeDispatchesInOrderStopAtTrueImpl(event) {
123
131
  if (event.isPropagationStopped()) {
124
132
  break;
125
133
  }
126
- // Listeners and IDs are two parallel arrays that are always in sync.
127
- if (dispatchListeners[i](event, dispatchIDs[i])) {
128
- return dispatchIDs[i];
134
+ // Listeners and Instances are two parallel arrays that are always in sync.
135
+ if (dispatchListeners[i](event, dispatchInstances[i])) {
136
+ return dispatchInstances[i];
129
137
  }
130
138
  }
131
139
  } else if (dispatchListeners) {
132
- if (dispatchListeners(event, dispatchIDs)) {
133
- return dispatchIDs;
140
+ if (dispatchListeners(event, dispatchInstances)) {
141
+ return dispatchInstances;
134
142
  }
135
143
  }
136
144
  return null;
@@ -141,7 +149,7 @@ function executeDispatchesInOrderStopAtTrueImpl(event) {
141
149
  */
142
150
  function executeDispatchesInOrderStopAtTrue(event) {
143
151
  var ret = executeDispatchesInOrderStopAtTrueImpl(event);
144
- event._dispatchIDs = null;
152
+ event._dispatchInstances = null;
145
153
  event._dispatchListeners = null;
146
154
  return ret;
147
155
  }
@@ -160,11 +168,13 @@ function executeDirectDispatch(event) {
160
168
  validateEventDispatches(event);
161
169
  }
162
170
  var dispatchListener = event._dispatchListeners;
163
- var dispatchID = event._dispatchIDs;
171
+ var dispatchInstance = event._dispatchInstances;
164
172
  !!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined;
165
- var res = dispatchListener ? dispatchListener(event, dispatchID) : null;
173
+ event.currentTarget = EventPluginUtils.getNodeFromInstance(dispatchInstance);
174
+ var res = dispatchListener ? dispatchListener(event) : null;
175
+ event.curentTarget = null;
166
176
  event._dispatchListeners = null;
167
- event._dispatchIDs = null;
177
+ event._dispatchInstances = null;
168
178
  return res;
169
179
  }
170
180
 
@@ -189,11 +199,26 @@ var EventPluginUtils = {
189
199
  executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
190
200
  hasDispatches: hasDispatches,
191
201
 
192
- getNode: function (id) {
193
- return injection.Mount.getNode(id);
202
+ getInstanceFromNode: function (node) {
203
+ return ComponentTree.getInstanceFromNode(node);
204
+ },
205
+ getNodeFromInstance: function (node) {
206
+ return ComponentTree.getNodeFromInstance(node);
207
+ },
208
+ isAncestor: function (a, b) {
209
+ return TreeTraversal.isAncestor(a, b);
210
+ },
211
+ getLowestCommonAncestor: function (a, b) {
212
+ return TreeTraversal.getLowestCommonAncestor(a, b);
213
+ },
214
+ getParentInstance: function (inst) {
215
+ return TreeTraversal.getParentInstance(inst);
216
+ },
217
+ traverseTwoPhase: function (target, fn, arg) {
218
+ return TreeTraversal.traverseTwoPhase(target, fn, arg);
194
219
  },
195
- getID: function (node) {
196
- return injection.Mount.getID(node);
220
+ traverseEnterLeave: function (from, to, fn, argFrom, argTo) {
221
+ return TreeTraversal.traverseEnterLeave(from, to, fn, argFrom, argTo);
197
222
  },
198
223
 
199
224
  injection: injection