react 0.14.10 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +4900 -4627
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +4556 -4059
  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 +10 -1
  9. package/lib/CSSPropertyOperations.js +49 -19
  10. package/lib/CallbackQueue.js +16 -4
  11. package/lib/ChangeEventPlugin.js +58 -54
  12. package/lib/DOMChildrenOperations.js +91 -61
  13. package/lib/DOMLazyTree.js +105 -0
  14. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  15. package/lib/DOMProperty.js +18 -39
  16. package/lib/DOMPropertyOperations.js +42 -53
  17. package/lib/Danger.js +13 -14
  18. package/lib/DefaultEventPluginOrder.js +1 -1
  19. package/lib/EnterLeaveEventPlugin.js +24 -43
  20. package/lib/EventConstants.js +6 -1
  21. package/lib/EventPluginHub.js +22 -66
  22. package/lib/EventPluginRegistry.js +30 -9
  23. package/lib/EventPluginUtils.js +61 -36
  24. package/lib/EventPropagators.js +19 -17
  25. package/lib/FallbackCompositionState.js +4 -4
  26. package/lib/HTMLDOMPropertyConfig.js +131 -152
  27. package/lib/LinkedStateMixin.js +1 -2
  28. package/lib/LinkedValueUtils.js +6 -7
  29. package/lib/MetaMatchers.js +2 -2
  30. package/lib/OrderedMap.js +17 -16
  31. package/lib/PooledClass.js +2 -2
  32. package/lib/React.js +50 -20
  33. package/lib/ReactBrowserEventEmitter.js +19 -26
  34. package/lib/ReactCSSTransitionGroup.js +4 -5
  35. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  36. package/lib/ReactChildReconciler.js +15 -13
  37. package/lib/ReactChildren.js +5 -4
  38. package/lib/ReactClass.js +44 -92
  39. package/lib/ReactComponent.js +9 -10
  40. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  41. package/lib/ReactComponentEnvironment.js +4 -4
  42. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  43. package/lib/ReactCompositeComponent.js +166 -74
  44. package/lib/ReactCurrentOwner.js +2 -1
  45. package/lib/ReactDOM.js +27 -15
  46. package/lib/ReactDOMButton.js +2 -2
  47. package/lib/ReactDOMComponent.js +186 -250
  48. package/lib/ReactDOMComponentFlags.js +18 -0
  49. package/lib/ReactDOMComponentTree.js +186 -0
  50. package/lib/ReactDOMContainerInfo.js +32 -0
  51. package/lib/ReactDOMDebugTool.js +61 -0
  52. package/lib/ReactDOMEmptyComponent.js +60 -0
  53. package/lib/ReactDOMFactories.js +1 -2
  54. package/lib/ReactDOMFeatureFlags.js +2 -2
  55. package/lib/ReactDOMIDOperations.js +5 -60
  56. package/lib/ReactDOMInput.js +73 -23
  57. package/lib/ReactDOMInstrumentation.js +16 -0
  58. package/lib/ReactDOMOption.js +14 -12
  59. package/lib/ReactDOMSelect.js +43 -19
  60. package/lib/ReactDOMSelection.js +4 -4
  61. package/lib/ReactDOMServer.js +1 -1
  62. package/lib/ReactDOMTextComponent.js +87 -45
  63. package/lib/ReactDOMTextarea.js +39 -11
  64. package/lib/ReactDOMTreeTraversal.js +134 -0
  65. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  66. package/lib/ReactDebugInstanceMap.js +102 -0
  67. package/lib/ReactDebugTool.js +72 -0
  68. package/lib/ReactDefaultBatchingStrategy.js +4 -3
  69. package/lib/ReactDefaultInjection.js +11 -15
  70. package/lib/ReactDefaultPerf.js +105 -26
  71. package/lib/ReactDefaultPerfAnalysis.js +23 -15
  72. package/lib/ReactElement.js +63 -23
  73. package/lib/ReactElementValidator.js +9 -9
  74. package/lib/ReactEmptyComponent.js +8 -33
  75. package/lib/ReactErrorUtils.js +1 -2
  76. package/lib/ReactEventEmitterMixin.js +3 -8
  77. package/lib/ReactEventListener.js +23 -77
  78. package/lib/ReactFeatureFlags.js +21 -0
  79. package/lib/ReactFragment.js +6 -6
  80. package/lib/ReactInjection.js +3 -3
  81. package/lib/ReactInputSelection.js +4 -4
  82. package/lib/ReactInstanceHandles.js +10 -12
  83. package/lib/ReactInstanceMap.js +2 -1
  84. package/lib/ReactInstrumentation.js +16 -0
  85. package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
  86. package/lib/ReactLink.js +2 -3
  87. package/lib/ReactMarkupChecksum.js +8 -3
  88. package/lib/ReactMount.js +88 -460
  89. package/lib/ReactMultiChild.js +106 -200
  90. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  91. package/lib/ReactNativeComponent.js +6 -5
  92. package/lib/ReactNodeTypes.js +37 -0
  93. package/lib/ReactNoopUpdateQueue.js +2 -25
  94. package/lib/ReactOwner.js +7 -6
  95. package/lib/ReactPerf.js +2 -2
  96. package/lib/ReactPropTransferer.js +5 -4
  97. package/lib/ReactPropTypeLocationNames.js +1 -1
  98. package/lib/ReactPropTypeLocations.js +1 -1
  99. package/lib/ReactPropTypes.js +31 -7
  100. package/lib/ReactReconcileTransaction.js +20 -9
  101. package/lib/ReactReconciler.js +29 -6
  102. package/lib/ReactRef.js +1 -1
  103. package/lib/ReactServerBatchingStrategy.js +1 -2
  104. package/lib/ReactServerRendering.js +17 -35
  105. package/lib/ReactServerRenderingTransaction.js +11 -29
  106. package/lib/ReactSimpleEmptyComponent.js +36 -0
  107. package/lib/ReactStateSetters.js +1 -1
  108. package/lib/ReactTestUtils.js +47 -28
  109. package/lib/ReactTransitionChildMapping.js +1 -2
  110. package/lib/ReactTransitionEvents.js +8 -44
  111. package/lib/ReactTransitionGroup.js +4 -3
  112. package/lib/ReactUMDEntry.js +26 -0
  113. package/lib/ReactUpdateQueue.js +24 -66
  114. package/lib/ReactUpdates.js +29 -11
  115. package/lib/ReactVersion.js +2 -2
  116. package/lib/ReactWithAddons.js +1 -21
  117. package/lib/ReactWithAddonsUMDEntry.js +26 -0
  118. package/lib/ResponderEventPlugin.js +54 -66
  119. package/lib/ResponderSyntheticEvent.js +2 -3
  120. package/lib/ResponderTouchHistoryStore.js +5 -5
  121. package/lib/SVGDOMPropertyConfig.js +267 -94
  122. package/lib/SelectEventPlugin.js +13 -18
  123. package/lib/SimpleEventPlugin.js +57 -17
  124. package/lib/SyntheticAnimationEvent.js +39 -0
  125. package/lib/SyntheticClipboardEvent.js +2 -3
  126. package/lib/SyntheticCompositionEvent.js +2 -3
  127. package/lib/SyntheticDragEvent.js +2 -3
  128. package/lib/SyntheticEvent.js +102 -21
  129. package/lib/SyntheticFocusEvent.js +2 -3
  130. package/lib/SyntheticInputEvent.js +2 -3
  131. package/lib/SyntheticKeyboardEvent.js +2 -3
  132. package/lib/SyntheticMouseEvent.js +2 -3
  133. package/lib/SyntheticTouchEvent.js +2 -3
  134. package/lib/SyntheticTransitionEvent.js +39 -0
  135. package/lib/SyntheticUIEvent.js +2 -3
  136. package/lib/SyntheticWheelEvent.js +2 -3
  137. package/lib/TapEventPlugin.js +3 -12
  138. package/lib/Transaction.js +3 -3
  139. package/lib/ViewportMetrics.js +1 -1
  140. package/lib/accumulate.js +2 -2
  141. package/lib/accumulateInto.js +2 -2
  142. package/lib/adler32.js +3 -2
  143. package/lib/canDefineProperty.js +1 -1
  144. package/lib/createHierarchyRenderer.js +1 -1
  145. package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
  146. package/lib/dangerousStyleValue.js +25 -3
  147. package/lib/deprecated.js +7 -4
  148. package/lib/escapeTextContentForBrowser.js +1 -1
  149. package/lib/findDOMNode.js +15 -8
  150. package/lib/flattenChildren.js +2 -2
  151. package/lib/forEachAccumulated.js +2 -1
  152. package/lib/getEventCharCode.js +2 -2
  153. package/lib/getEventKey.js +1 -2
  154. package/lib/getEventModifierState.js +1 -2
  155. package/lib/getEventTarget.js +8 -2
  156. package/lib/getIteratorFn.js +2 -2
  157. package/lib/getNativeComponentFromComposite.js +30 -0
  158. package/lib/getNodeForCharacterOffset.js +2 -1
  159. package/lib/getTestDocument.js +1 -1
  160. package/lib/getTextContentAccessor.js +1 -1
  161. package/lib/getVendorPrefixedEventName.js +101 -0
  162. package/lib/instantiateReactComponent.js +12 -13
  163. package/lib/isEventSupported.js +2 -2
  164. package/lib/isTextInputElement.js +2 -1
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/quoteAttributeValueForBrowser.js +1 -1
  167. package/lib/reactComponentExpect.js +5 -4
  168. package/lib/renderSubtreeIntoContainer.js +1 -1
  169. package/lib/setInnerHTML.js +6 -14
  170. package/lib/setTextContent.js +1 -1
  171. package/lib/shallowCompare.js +1 -1
  172. package/lib/shouldUpdateReactComponent.js +2 -3
  173. package/lib/sliceChildren.js +1 -1
  174. package/lib/traverseAllChildren.js +8 -8
  175. package/lib/update.js +16 -15
  176. package/lib/validateDOMNesting.js +18 -13
  177. package/package.json +23 -32
  178. package/addons.js +0 -13
  179. package/cjs/react-jsx-dev-runtime.development.js +0 -861
  180. package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  181. package/cjs/react-jsx-runtime.development.js +0 -883
  182. package/cjs/react-jsx-runtime.production.min.js +0 -10
  183. package/jsx-dev-runtime.js +0 -7
  184. package/jsx-runtime.js +0 -7
  185. package/lib/Object.assign.js +0 -47
  186. package/lib/React.native.js +0 -5
  187. package/lib/ReactBrowserComponentMixin.js +0 -36
  188. package/lib/ReactEmptyComponentRegistry.js +0 -48
  189. package/lib/ReactIsomorphic.js +0 -74
  190. package/lib/ReactRootIndex.js +0 -29
  191. package/lib/ServerReactRootIndex.js +0 -29
  192. package/lib/cloneWithProps.js +0 -54
  193. 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
@@ -11,9 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _assign = require('object-assign');
15
+
14
16
  var ReactCurrentOwner = require('./ReactCurrentOwner');
15
17
 
16
- var assign = require('./Object.assign');
18
+ var warning = require('fbjs/lib/warning');
17
19
  var canDefineProperty = require('./canDefineProperty');
18
20
 
19
21
  // The Symbol used to tag the ReactElement type. If there is no native Symbol
@@ -27,9 +29,13 @@ var RESERVED_PROPS = {
27
29
  __source: true
28
30
  };
29
31
 
32
+ var specialPropKeyWarningShown, specialPropRefWarningShown;
33
+
30
34
  /**
31
- * Base constructor for all React elements. This is only used to make this
32
- * work with a dynamic instanceof check. Nothing should live on this prototype.
35
+ * Factory method to create a new React element. This no longer adheres to
36
+ * the class pattern, so do not use new to call it. Also, no instanceof check
37
+ * will work. Instead test $$typeof field against Symbol.for('react.element') to check
38
+ * if something is a React Element.
33
39
  *
34
40
  * @param {*} type
35
41
  * @param {*} key
@@ -98,8 +104,10 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
98
104
  element._self = self;
99
105
  element._source = source;
100
106
  }
101
- Object.freeze(element.props);
102
- Object.freeze(element);
107
+ if (Object.freeze) {
108
+ Object.freeze(element.props);
109
+ Object.freeze(element);
110
+ }
103
111
  }
104
112
 
105
113
  return element;
@@ -117,8 +125,13 @@ ReactElement.createElement = function (type, config, children) {
117
125
  var source = null;
118
126
 
119
127
  if (config != null) {
120
- ref = config.ref === undefined ? null : config.ref;
121
- key = config.key === undefined ? null : '' + config.key;
128
+ if (process.env.NODE_ENV !== 'production') {
129
+ ref = !config.hasOwnProperty('ref') || Object.getOwnPropertyDescriptor(config, 'ref').get ? null : config.ref;
130
+ key = !config.hasOwnProperty('key') || Object.getOwnPropertyDescriptor(config, 'key').get ? null : '' + config.key;
131
+ } else {
132
+ ref = config.ref === undefined ? null : config.ref;
133
+ key = config.key === undefined ? null : '' + config.key;
134
+ }
122
135
  self = config.__self === undefined ? null : config.__self;
123
136
  source = config.__source === undefined ? null : config.__source;
124
137
  // Remaining properties are added to a new props object
@@ -146,12 +159,41 @@ ReactElement.createElement = function (type, config, children) {
146
159
  if (type && type.defaultProps) {
147
160
  var defaultProps = type.defaultProps;
148
161
  for (propName in defaultProps) {
149
- if (typeof props[propName] === 'undefined') {
162
+ if (props[propName] === undefined) {
150
163
  props[propName] = defaultProps[propName];
151
164
  }
152
165
  }
153
166
  }
154
-
167
+ if (process.env.NODE_ENV !== 'production') {
168
+ // Create dummy `key` and `ref` property to `props` to warn users
169
+ // against its use
170
+ if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
171
+ if (!props.hasOwnProperty('key')) {
172
+ Object.defineProperty(props, 'key', {
173
+ get: function () {
174
+ if (!specialPropKeyWarningShown) {
175
+ specialPropKeyWarningShown = true;
176
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', typeof type === 'function' && 'displayName' in type ? type.displayName : 'Element') : void 0;
177
+ }
178
+ return undefined;
179
+ },
180
+ configurable: true
181
+ });
182
+ }
183
+ if (!props.hasOwnProperty('ref')) {
184
+ Object.defineProperty(props, 'ref', {
185
+ get: function () {
186
+ if (!specialPropRefWarningShown) {
187
+ specialPropRefWarningShown = true;
188
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', typeof type === 'function' && 'displayName' in type ? type.displayName : 'Element') : void 0;
189
+ }
190
+ return undefined;
191
+ },
192
+ configurable: true
193
+ });
194
+ }
195
+ }
196
+ }
155
197
  return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
156
198
  };
157
199
 
@@ -172,22 +214,11 @@ ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
172
214
  return newElement;
173
215
  };
174
216
 
175
- ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
176
- var newElement = ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, newProps);
177
-
178
- if (process.env.NODE_ENV !== 'production') {
179
- // If the key on the original is valid, then the clone is valid
180
- newElement._store.validated = oldElement._store.validated;
181
- }
182
-
183
- return newElement;
184
- };
185
-
186
217
  ReactElement.cloneElement = function (element, config, children) {
187
218
  var propName;
188
219
 
189
220
  // Original props are copied
190
- var props = assign({}, element.props);
221
+ var props = _assign({}, element.props);
191
222
 
192
223
  // Reserved names are extracted
193
224
  var key = element.key;
@@ -212,9 +243,18 @@ ReactElement.cloneElement = function (element, config, children) {
212
243
  key = '' + config.key;
213
244
  }
214
245
  // Remaining properties override existing props
246
+ var defaultProps;
247
+ if (element.type && element.type.defaultProps) {
248
+ defaultProps = element.type.defaultProps;
249
+ }
215
250
  for (propName in config) {
216
251
  if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
217
- props[propName] = config[propName];
252
+ if (config[propName] === undefined && defaultProps !== undefined) {
253
+ // Resolve default props
254
+ props[propName] = defaultProps[propName];
255
+ } else {
256
+ props[propName] = config[propName];
257
+ }
218
258
  }
219
259
  }
220
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
@@ -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;
178
- error = propTypes[propName](props, propName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
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
+ 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,40 +7,36 @@
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';
14
13
 
14
+ var _assign = require('object-assign');
15
+
15
16
  var EventListener = require('fbjs/lib/EventListener');
16
17
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
17
18
  var PooledClass = require('./PooledClass');
18
- var ReactInstanceHandles = require('./ReactInstanceHandles');
19
- var ReactMount = require('./ReactMount');
19
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
20
20
  var ReactUpdates = require('./ReactUpdates');
21
21
 
22
- var assign = require('./Object.assign');
23
22
  var getEventTarget = require('./getEventTarget');
24
23
  var getUnboundedScrollPosition = require('fbjs/lib/getUnboundedScrollPosition');
25
24
 
26
- var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
27
-
28
25
  /**
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.
26
+ * Find the deepest React component completely containing the root of the
27
+ * passed-in instance (for use when entire React trees are nested within each
28
+ * other). If React trees are not nested, returns null.
34
29
  */
35
- function findParent(node) {
30
+ function findParent(inst) {
36
31
  // TODO: It may be a good idea to cache this to prevent unnecessary DOM
37
32
  // traversal, but caching is difficult to do correctly without using a
38
33
  // 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;
34
+ while (inst._nativeParent) {
35
+ inst = inst._nativeParent;
36
+ }
37
+ var rootNode = ReactDOMComponentTree.getNodeFromInstance(inst);
38
+ var container = rootNode.parentNode;
39
+ return ReactDOMComponentTree.getClosestInstanceFromNode(container);
44
40
  }
45
41
 
46
42
  // Used to store ancestor hierarchy in top level callback
@@ -49,7 +45,7 @@ function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
49
45
  this.nativeEvent = nativeEvent;
50
46
  this.ancestors = [];
51
47
  }
52
- assign(TopLevelCallbackBookKeeping.prototype, {
48
+ _assign(TopLevelCallbackBookKeeping.prototype, {
53
49
  destructor: function () {
54
50
  this.topLevelType = null;
55
51
  this.nativeEvent = null;
@@ -59,72 +55,22 @@ assign(TopLevelCallbackBookKeeping.prototype, {
59
55
  PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
60
56
 
61
57
  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;
58
+ var nativeEventTarget = getEventTarget(bookKeeping.nativeEvent);
59
+ var targetInst = ReactDOMComponentTree.getClosestInstanceFromNode(nativeEventTarget);
79
60
 
80
61
  // Loop through the hierarchy, in case there's any nested components.
81
62
  // It's important that we build the array of ancestors before calling any
82
63
  // event handlers, because event handlers can modify the DOM, leading to
83
64
  // inconsistencies with ReactMount's node cache. See #1105.
84
- var ancestor = topLevelTarget;
85
- while (ancestor) {
65
+ var ancestor = targetInst;
66
+ do {
86
67
  bookKeeping.ancestors.push(ancestor);
87
- ancestor = findParent(ancestor);
88
- }
68
+ ancestor = ancestor && findParent(ancestor);
69
+ } while (ancestor);
89
70
 
90
71
  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));
72
+ targetInst = bookKeeping.ancestors[i];
73
+ ReactEventListener._handleTopLevel(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
128
74
  }
129
75
  }
130
76