react 0.13.3 → 0.14.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/README.md +5 -2
  2. package/addons.js +7 -0
  3. package/dist/JSXTransformer.js +4101 -2432
  4. package/dist/react-with-addons.js +4389 -6277
  5. package/dist/react-with-addons.min.js +6 -8
  6. package/dist/react.js +4028 -5697
  7. package/dist/react.min.js +5 -6
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
  9. package/lib/BeforeInputEventPlugin.js +30 -118
  10. package/lib/CSSCore.js +12 -23
  11. package/lib/CSSProperty.js +4 -3
  12. package/lib/CSSPropertyOperations.js +14 -30
  13. package/lib/CallbackQueue.js +7 -10
  14. package/lib/ChangeEventPlugin.js +26 -88
  15. package/lib/ClientReactRootIndex.js +2 -2
  16. package/lib/DOMChildrenOperations.js +13 -33
  17. package/lib/DOMProperty.js +86 -147
  18. package/lib/DOMPropertyOperations.js +91 -67
  19. package/lib/Danger.js +19 -62
  20. package/lib/DefaultEventPluginOrder.js +2 -12
  21. package/lib/EnterLeaveEventPlugin.js +11 -33
  22. package/lib/EventConstants.js +2 -2
  23. package/lib/EventListener.js +11 -13
  24. package/lib/EventPluginHub.js +44 -47
  25. package/lib/EventPluginRegistry.js +18 -74
  26. package/lib/EventPluginUtils.js +33 -44
  27. package/lib/EventPropagators.js +23 -26
  28. package/lib/ExecutionEnvironment.js +4 -8
  29. package/lib/FallbackCompositionState.js +3 -3
  30. package/lib/HTMLDOMPropertyConfig.js +15 -20
  31. package/lib/LinkedStateMixin.js +3 -6
  32. package/lib/LinkedValueUtils.js +71 -89
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +20 -11
  35. package/lib/React.js +9 -129
  36. package/lib/ReactBrowserComponentMixin.js +9 -2
  37. package/lib/ReactBrowserEventEmitter.js +26 -82
  38. package/lib/ReactCSSTransitionGroup.js +13 -24
  39. package/lib/ReactCSSTransitionGroupChild.js +26 -28
  40. package/lib/ReactChildReconciler.js +11 -19
  41. package/lib/ReactChildren.js +24 -31
  42. package/lib/ReactClass.js +96 -267
  43. package/lib/ReactComponent.js +28 -57
  44. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  45. package/lib/ReactComponentEnvironment.js +6 -12
  46. package/lib/ReactComponentWithPureRenderMixin.js +6 -7
  47. package/lib/ReactCompositeComponent.js +115 -381
  48. package/lib/ReactCurrentOwner.js +1 -3
  49. package/lib/ReactDOM.js +4 -2
  50. package/lib/ReactDOMButton.js +16 -28
  51. package/lib/ReactDOMClient.js +90 -0
  52. package/lib/ReactDOMComponent.js +468 -156
  53. package/lib/ReactDOMIDOperations.js +25 -22
  54. package/lib/ReactDOMInput.js +79 -108
  55. package/lib/ReactDOMOption.js +58 -20
  56. package/lib/ReactDOMSelect.js +95 -83
  57. package/lib/ReactDOMSelection.js +5 -20
  58. package/lib/ReactDOMServer.js +24 -0
  59. package/lib/ReactDOMTextComponent.js +17 -18
  60. package/lib/ReactDOMTextarea.js +44 -69
  61. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  62. package/lib/ReactDefaultInjection.js +20 -76
  63. package/lib/ReactDefaultPerf.js +36 -69
  64. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  65. package/lib/ReactElement.js +26 -120
  66. package/lib/ReactElementValidator.js +56 -192
  67. package/lib/ReactEmptyComponent.js +7 -11
  68. package/lib/ReactErrorUtils.js +3 -3
  69. package/lib/ReactEventEmitterMixin.js +3 -13
  70. package/lib/ReactEventListener.js +58 -40
  71. package/lib/ReactFragment.js +33 -59
  72. package/lib/ReactInjection.js +1 -1
  73. package/lib/ReactInputSelection.js +14 -23
  74. package/lib/ReactInstanceHandles.js +29 -58
  75. package/lib/ReactInstanceMap.js +5 -5
  76. package/lib/ReactIsomorphic.js +70 -0
  77. package/lib/ReactLink.js +2 -4
  78. package/lib/ReactMarkupChecksum.js +5 -10
  79. package/lib/ReactMount.js +142 -285
  80. package/lib/ReactMultiChild.js +19 -45
  81. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  82. package/lib/ReactNativeComponent.js +6 -15
  83. package/lib/ReactNoopUpdateQueue.js +118 -0
  84. package/lib/ReactOwner.js +7 -24
  85. package/lib/ReactPerf.js +8 -12
  86. package/lib/ReactPropTransferer.js +4 -4
  87. package/lib/ReactPropTypeLocationNames.js +2 -2
  88. package/lib/ReactPropTypeLocations.js +1 -1
  89. package/lib/ReactPropTypes.js +41 -61
  90. package/lib/ReactReconcileTransaction.js +11 -36
  91. package/lib/ReactReconciler.js +14 -26
  92. package/lib/ReactRef.js +5 -8
  93. package/lib/ReactRootIndex.js +2 -2
  94. package/lib/ReactServerBatchingStrategy.js +23 -0
  95. package/lib/ReactServerRendering.js +20 -15
  96. package/lib/ReactServerRenderingTransaction.js +9 -34
  97. package/lib/ReactStateSetters.js +6 -6
  98. package/lib/ReactTestUtils.js +137 -190
  99. package/lib/ReactTransitionChildMapping.js +5 -7
  100. package/lib/ReactTransitionEvents.js +5 -5
  101. package/lib/ReactTransitionGroup.js +30 -52
  102. package/lib/ReactUpdateQueue.js +69 -107
  103. package/lib/ReactUpdates.js +26 -81
  104. package/lib/ReactWithAddons.js +5 -6
  105. package/lib/SVGDOMPropertyConfig.js +39 -4
  106. package/lib/SelectEventPlugin.js +31 -33
  107. package/lib/ServerReactRootIndex.js +2 -2
  108. package/lib/SimpleEventPlugin.js +138 -130
  109. package/lib/SyntheticClipboardEvent.js +5 -9
  110. package/lib/SyntheticCompositionEvent.js +4 -10
  111. package/lib/SyntheticDragEvent.js +3 -3
  112. package/lib/SyntheticEvent.js +14 -15
  113. package/lib/SyntheticFocusEvent.js +3 -3
  114. package/lib/SyntheticInputEvent.js +4 -10
  115. package/lib/SyntheticKeyboardEvent.js +6 -6
  116. package/lib/SyntheticMouseEvent.js +10 -16
  117. package/lib/SyntheticTouchEvent.js +3 -3
  118. package/lib/SyntheticUIEvent.js +5 -5
  119. package/lib/SyntheticWheelEvent.js +13 -17
  120. package/lib/Transaction.js +22 -28
  121. package/lib/ViewportMetrics.js +2 -2
  122. package/lib/accumulateInto.js +2 -5
  123. package/lib/adler32.js +2 -4
  124. package/lib/camelize.js +4 -2
  125. package/lib/camelizeStyleName.js +2 -2
  126. package/lib/cloneWithProps.js +6 -12
  127. package/lib/containsNode.js +29 -16
  128. package/lib/createArrayFromMixed.js +17 -16
  129. package/lib/createNodesFromMarkup.js +6 -8
  130. package/lib/dangerousStyleValue.js +2 -3
  131. package/lib/deprecated.js +47 -0
  132. package/lib/emptyFunction.js +10 -4
  133. package/lib/emptyObject.js +1 -1
  134. package/lib/escapeTextContentForBrowser.js +1 -1
  135. package/lib/findDOMNode.js +7 -27
  136. package/lib/flattenChildren.js +4 -10
  137. package/lib/focusNode.js +2 -3
  138. package/lib/forEachAccumulated.js +3 -3
  139. package/lib/getActiveElement.js +4 -2
  140. package/lib/getEventCharCode.js +2 -2
  141. package/lib/getEventKey.js +1 -1
  142. package/lib/getEventModifierState.js +1 -2
  143. package/lib/getEventTarget.js +1 -1
  144. package/lib/getIteratorFn.js +2 -4
  145. package/lib/getMarkupWrap.js +18 -40
  146. package/lib/getNodeForCharacterOffset.js +1 -1
  147. package/lib/getTextContentAccessor.js +2 -4
  148. package/lib/getUnboundedScrollPosition.js +1 -1
  149. package/lib/hyphenate.js +3 -1
  150. package/lib/hyphenateStyleName.js +2 -2
  151. package/lib/instantiateReactComponent.js +23 -43
  152. package/lib/invariant.js +8 -12
  153. package/lib/isEventSupported.js +7 -10
  154. package/lib/isNode.js +4 -6
  155. package/lib/isTextInputElement.js +3 -4
  156. package/lib/isTextNode.js +3 -1
  157. package/lib/joinClasses.js +3 -3
  158. package/lib/keyMirror.js +3 -6
  159. package/lib/keyOf.js +4 -3
  160. package/lib/mapObject.js +1 -1
  161. package/lib/memoizeStringOnly.js +2 -2
  162. package/lib/onlyChild.js +2 -5
  163. package/lib/performance.js +2 -5
  164. package/lib/performanceNow.js +3 -1
  165. package/lib/quoteAttributeValueForBrowser.js +1 -1
  166. package/lib/renderSubtreeIntoContainer.js +16 -0
  167. package/lib/setInnerHTML.js +11 -8
  168. package/lib/setTextContent.js +3 -3
  169. package/lib/shallowCompare.js +24 -0
  170. package/lib/shallowEqual.js +17 -11
  171. package/lib/shouldUpdateReactComponent.js +3 -64
  172. package/lib/toArray.js +8 -19
  173. package/lib/traverseAllChildren.js +23 -90
  174. package/lib/update.js +25 -85
  175. package/lib/validateDOMNesting.js +363 -0
  176. package/lib/warning.js +15 -17
  177. package/package.json +3 -3
  178. package/react.js +53 -1
  179. package/lib/LocalEventTrapMixin.js +0 -53
  180. package/lib/MobileSafariClickEventPlugin.js +0 -56
  181. package/lib/ReactContext.js +0 -74
  182. package/lib/ReactDOMForm.js +0 -47
  183. package/lib/ReactDOMIframe.js +0 -43
  184. package/lib/ReactDOMImg.js +0 -44
  185. package/lib/ReactLifeCycle.js +0 -35
  186. package/lib/ReactPutListenerQueue.js +0 -54
  187. package/lib/createFullPageComponent.js +0 -58
  188. package/lib/cx.js +0 -52
  189. package/lib/getReactRootElementInContainer.js +0 -33
@@ -17,15 +17,32 @@ var DOMProperty = require("./DOMProperty");
17
17
  var quoteAttributeValueForBrowser = require("./quoteAttributeValueForBrowser");
18
18
  var warning = require("./warning");
19
19
 
20
- function shouldIgnoreValue(name, value) {
21
- return value == null ||
22
- (DOMProperty.hasBooleanValue[name] && !value) ||
23
- (DOMProperty.hasNumericValue[name] && isNaN(value)) ||
24
- (DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
25
- (DOMProperty.hasOverloadedBooleanValue[name] && value === false);
20
+ // Simplified subset
21
+ var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][a-zA-Z_\.\-\d]*$/;
22
+ var illegalAttributeNameCache = {};
23
+ var validatedAttributeNameCache = {};
24
+
25
+ function isAttributeNameSafe(attributeName) {
26
+ if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
27
+ return true;
28
+ }
29
+ if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
30
+ return false;
31
+ }
32
+ if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
33
+ validatedAttributeNameCache[attributeName] = true;
34
+ return true;
35
+ }
36
+ illegalAttributeNameCache[attributeName] = true;
37
+ 'production' !== process.env.NODE_ENV ? warning(false, 'Invalid attribute name: `%s`', attributeName) : undefined;
38
+ return false;
26
39
  }
27
40
 
28
- if ("production" !== process.env.NODE_ENV) {
41
+ function shouldIgnoreValue(propertyInfo, value) {
42
+ return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
43
+ }
44
+
45
+ if ('production' !== process.env.NODE_ENV) {
29
46
  var reactProps = {
30
47
  children: true,
31
48
  dangerouslySetInnerHTML: true,
@@ -34,9 +51,8 @@ if ("production" !== process.env.NODE_ENV) {
34
51
  };
35
52
  var warnedProperties = {};
36
53
 
37
- var warnUnknownProperty = function(name) {
38
- if (reactProps.hasOwnProperty(name) && reactProps[name] ||
39
- warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
54
+ var warnUnknownProperty = function (name) {
55
+ if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
40
56
  return;
41
57
  }
42
58
 
@@ -44,23 +60,11 @@ if ("production" !== process.env.NODE_ENV) {
44
60
  var lowerCasedName = name.toLowerCase();
45
61
 
46
62
  // data-* attributes should be lowercase; suggest the lowercase version
47
- var standardName = (
48
- DOMProperty.isCustomAttribute(lowerCasedName) ?
49
- lowerCasedName :
50
- DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
51
- DOMProperty.getPossibleStandardName[lowerCasedName] :
52
- null
53
- );
63
+ var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
54
64
 
55
65
  // For now, only warn when we have a suggested correction. This prevents
56
66
  // logging too much when using transferPropsTo.
57
- ("production" !== process.env.NODE_ENV ? warning(
58
- standardName == null,
59
- 'Unknown DOM property %s. Did you mean %s?',
60
- name,
61
- standardName
62
- ) : null);
63
-
67
+ 'production' !== process.env.NODE_ENV ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
64
68
  };
65
69
  }
66
70
 
@@ -75,9 +79,8 @@ var DOMPropertyOperations = {
75
79
  * @param {string} id Unescaped ID.
76
80
  * @return {string} Markup string.
77
81
  */
78
- createMarkupForID: function(id) {
79
- return DOMProperty.ID_ATTRIBUTE_NAME + '=' +
80
- quoteAttributeValueForBrowser(id);
82
+ createMarkupForID: function (id) {
83
+ return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
81
84
  },
82
85
 
83
86
  /**
@@ -87,16 +90,15 @@ var DOMPropertyOperations = {
87
90
  * @param {*} value
88
91
  * @return {?string} Markup string, or null if the property was invalid.
89
92
  */
90
- createMarkupForProperty: function(name, value) {
91
- if (DOMProperty.isStandardName.hasOwnProperty(name) &&
92
- DOMProperty.isStandardName[name]) {
93
- if (shouldIgnoreValue(name, value)) {
93
+ createMarkupForProperty: function (name, value) {
94
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
95
+ if (propertyInfo) {
96
+ if (shouldIgnoreValue(propertyInfo, value)) {
94
97
  return '';
95
98
  }
96
- var attributeName = DOMProperty.getAttributeName[name];
97
- if (DOMProperty.hasBooleanValue[name] ||
98
- (DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
99
- return attributeName;
99
+ var attributeName = propertyInfo.attributeName;
100
+ if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
101
+ return attributeName + '=""';
100
102
  }
101
103
  return attributeName + '=' + quoteAttributeValueForBrowser(value);
102
104
  } else if (DOMProperty.isCustomAttribute(name)) {
@@ -104,12 +106,26 @@ var DOMPropertyOperations = {
104
106
  return '';
105
107
  }
106
108
  return name + '=' + quoteAttributeValueForBrowser(value);
107
- } else if ("production" !== process.env.NODE_ENV) {
109
+ } else if ('production' !== process.env.NODE_ENV) {
108
110
  warnUnknownProperty(name);
109
111
  }
110
112
  return null;
111
113
  },
112
114
 
115
+ /**
116
+ * Creates markup for a custom property.
117
+ *
118
+ * @param {string} name
119
+ * @param {*} value
120
+ * @return {string} Markup string, or empty string if the property was invalid.
121
+ */
122
+ createMarkupForCustomAttribute: function (name, value) {
123
+ if (!isAttributeNameSafe(name) || value == null) {
124
+ return '';
125
+ }
126
+ return name + '=' + quoteAttributeValueForBrowser(value);
127
+ },
128
+
113
129
  /**
114
130
  * Sets the value for a property on a node.
115
131
  *
@@ -117,72 +133,80 @@ var DOMPropertyOperations = {
117
133
  * @param {string} name
118
134
  * @param {*} value
119
135
  */
120
- setValueForProperty: function(node, name, value) {
121
- if (DOMProperty.isStandardName.hasOwnProperty(name) &&
122
- DOMProperty.isStandardName[name]) {
123
- var mutationMethod = DOMProperty.getMutationMethod[name];
136
+ setValueForProperty: function (node, name, value) {
137
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
138
+ if (propertyInfo) {
139
+ var mutationMethod = propertyInfo.mutationMethod;
124
140
  if (mutationMethod) {
125
141
  mutationMethod(node, value);
126
- } else if (shouldIgnoreValue(name, value)) {
142
+ } else if (shouldIgnoreValue(propertyInfo, value)) {
127
143
  this.deleteValueForProperty(node, name);
128
- } else if (DOMProperty.mustUseAttribute[name]) {
144
+ } else if (propertyInfo.mustUseAttribute) {
145
+ var attributeName = propertyInfo.attributeName;
146
+ var namespace = propertyInfo.attributeNamespace;
129
147
  // `setAttribute` with objects becomes only `[object]` in IE8/9,
130
148
  // ('' + value) makes it output the correct toString()-value.
131
- node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
149
+ if (namespace) {
150
+ node.setAttributeNS(namespace, attributeName, '' + value);
151
+ } else {
152
+ node.setAttribute(attributeName, '' + value);
153
+ }
132
154
  } else {
133
- var propName = DOMProperty.getPropertyName[name];
155
+ var propName = propertyInfo.propertyName;
134
156
  // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
135
157
  // property type before comparing; only `value` does and is string.
136
- if (!DOMProperty.hasSideEffects[name] ||
137
- ('' + node[propName]) !== ('' + value)) {
158
+ if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) {
138
159
  // Contrary to `setAttribute`, object properties are properly
139
160
  // `toString`ed by IE8/9.
140
161
  node[propName] = value;
141
162
  }
142
163
  }
143
164
  } else if (DOMProperty.isCustomAttribute(name)) {
144
- if (value == null) {
145
- node.removeAttribute(name);
146
- } else {
147
- node.setAttribute(name, '' + value);
148
- }
149
- } else if ("production" !== process.env.NODE_ENV) {
165
+ DOMPropertyOperations.setValueForAttribute(node, name, value);
166
+ } else if ('production' !== process.env.NODE_ENV) {
150
167
  warnUnknownProperty(name);
151
168
  }
152
169
  },
153
170
 
171
+ setValueForAttribute: function (node, name, value) {
172
+ if (!isAttributeNameSafe(name)) {
173
+ return;
174
+ }
175
+ if (value == null) {
176
+ node.removeAttribute(name);
177
+ } else {
178
+ node.setAttribute(name, '' + value);
179
+ }
180
+ },
181
+
154
182
  /**
155
183
  * Deletes the value for a property on a node.
156
184
  *
157
185
  * @param {DOMElement} node
158
186
  * @param {string} name
159
187
  */
160
- deleteValueForProperty: function(node, name) {
161
- if (DOMProperty.isStandardName.hasOwnProperty(name) &&
162
- DOMProperty.isStandardName[name]) {
163
- var mutationMethod = DOMProperty.getMutationMethod[name];
188
+ deleteValueForProperty: function (node, name) {
189
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
190
+ if (propertyInfo) {
191
+ var mutationMethod = propertyInfo.mutationMethod;
164
192
  if (mutationMethod) {
165
193
  mutationMethod(node, undefined);
166
- } else if (DOMProperty.mustUseAttribute[name]) {
167
- node.removeAttribute(DOMProperty.getAttributeName[name]);
194
+ } else if (propertyInfo.mustUseAttribute) {
195
+ node.removeAttribute(propertyInfo.attributeName);
168
196
  } else {
169
- var propName = DOMProperty.getPropertyName[name];
170
- var defaultValue = DOMProperty.getDefaultValueForProperty(
171
- node.nodeName,
172
- propName
173
- );
174
- if (!DOMProperty.hasSideEffects[name] ||
175
- ('' + node[propName]) !== defaultValue) {
197
+ var propName = propertyInfo.propertyName;
198
+ var defaultValue = DOMProperty.getDefaultValueForProperty(node.nodeName, propName);
199
+ if (!propertyInfo.hasSideEffects || '' + node[propName] !== defaultValue) {
176
200
  node[propName] = defaultValue;
177
201
  }
178
202
  }
179
203
  } else if (DOMProperty.isCustomAttribute(name)) {
180
204
  node.removeAttribute(name);
181
- } else if ("production" !== process.env.NODE_ENV) {
205
+ } else if ('production' !== process.env.NODE_ENV) {
182
206
  warnUnknownProperty(name);
183
207
  }
184
208
  }
185
209
 
186
210
  };
187
211
 
188
- module.exports = DOMPropertyOperations;
212
+ module.exports = DOMPropertyOperations;
package/lib/Danger.js CHANGED
@@ -10,8 +10,6 @@
10
10
  * @typechecks static-only
11
11
  */
12
12
 
13
- /*jslint evil: true, sub: true */
14
-
15
13
  'use strict';
16
14
 
17
15
  var ExecutionEnvironment = require("./ExecutionEnvironment");
@@ -50,22 +48,13 @@ var Danger = {
50
48
  * @return {array<DOMElement>} List of rendered nodes.
51
49
  * @internal
52
50
  */
53
- dangerouslyRenderMarkup: function(markupList) {
54
- ("production" !== process.env.NODE_ENV ? invariant(
55
- ExecutionEnvironment.canUseDOM,
56
- 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
57
- 'thread. Make sure `window` and `document` are available globally ' +
58
- 'before requiring React when unit testing or use ' +
59
- 'React.renderToString for server rendering.'
60
- ) : invariant(ExecutionEnvironment.canUseDOM));
51
+ dangerouslyRenderMarkup: function (markupList) {
52
+ !ExecutionEnvironment.canUseDOM ? 'production' !== process.env.NODE_ENV ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'React.renderToString for server rendering.') : invariant(false) : undefined;
61
53
  var nodeName;
62
54
  var markupByNodeName = {};
63
55
  // Group markup by `nodeName` if a wrap is necessary, else by '*'.
64
56
  for (var i = 0; i < markupList.length; i++) {
65
- ("production" !== process.env.NODE_ENV ? invariant(
66
- markupList[i],
67
- 'dangerouslyRenderMarkup(...): Missing markup.'
68
- ) : invariant(markupList[i]));
57
+ !markupList[i] ? 'production' !== process.env.NODE_ENV ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined;
69
58
  nodeName = getNodeName(markupList[i]);
70
59
  nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
71
60
  markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
@@ -90,61 +79,41 @@ var Danger = {
90
79
  // Push the requested markup with an additional RESULT_INDEX_ATTR
91
80
  // attribute. If the markup does not start with a < character, it
92
81
  // will be discarded below (with an appropriate console.error).
93
- markupListByNodeName[resultIndex] = markup.replace(
94
- OPEN_TAG_NAME_EXP,
95
- // This index will be parsed back out below.
96
- '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
97
- );
82
+ markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP,
83
+ // This index will be parsed back out below.
84
+ '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" ');
98
85
  }
99
86
  }
100
87
 
101
88
  // Render each group of markup with similar wrapping `nodeName`.
102
- var renderNodes = createNodesFromMarkup(
103
- markupListByNodeName.join(''),
104
- emptyFunction // Do nothing special with <script> tags.
89
+ var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with <script> tags.
105
90
  );
106
91
 
107
92
  for (var j = 0; j < renderNodes.length; ++j) {
108
93
  var renderNode = renderNodes[j];
109
- if (renderNode.hasAttribute &&
110
- renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
94
+ if (renderNode.hasAttribute && renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
111
95
 
112
96
  resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
113
97
  renderNode.removeAttribute(RESULT_INDEX_ATTR);
114
98
 
115
- ("production" !== process.env.NODE_ENV ? invariant(
116
- !resultList.hasOwnProperty(resultIndex),
117
- 'Danger: Assigning to an already-occupied result index.'
118
- ) : invariant(!resultList.hasOwnProperty(resultIndex)));
99
+ !!resultList.hasOwnProperty(resultIndex) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Danger: Assigning to an already-occupied result index.') : invariant(false) : undefined;
119
100
 
120
101
  resultList[resultIndex] = renderNode;
121
102
 
122
103
  // This should match resultList.length and markupList.length when
123
104
  // we're done.
124
105
  resultListAssignmentCount += 1;
125
-
126
- } else if ("production" !== process.env.NODE_ENV) {
127
- console.error(
128
- 'Danger: Discarding unexpected node:',
129
- renderNode
130
- );
106
+ } else if ('production' !== process.env.NODE_ENV) {
107
+ console.error('Danger: Discarding unexpected node:', renderNode);
131
108
  }
132
109
  }
133
110
  }
134
111
 
135
112
  // Although resultList was populated out of order, it should now be a dense
136
113
  // array.
137
- ("production" !== process.env.NODE_ENV ? invariant(
138
- resultListAssignmentCount === resultList.length,
139
- 'Danger: Did not assign to every index of resultList.'
140
- ) : invariant(resultListAssignmentCount === resultList.length));
141
-
142
- ("production" !== process.env.NODE_ENV ? invariant(
143
- resultList.length === markupList.length,
144
- 'Danger: Expected markup to render %s nodes, but rendered %s.',
145
- markupList.length,
146
- resultList.length
147
- ) : invariant(resultList.length === markupList.length));
114
+ !(resultListAssignmentCount === resultList.length) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Danger: Did not assign to every index of resultList.') : invariant(false) : undefined;
115
+
116
+ !(resultList.length === markupList.length) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Danger: Expected markup to render %s nodes, but rendered %s.', markupList.length, resultList.length) : invariant(false) : undefined;
148
117
 
149
118
  return resultList;
150
119
  },
@@ -157,22 +126,10 @@ var Danger = {
157
126
  * @param {string} markup Markup to render in place of the child node.
158
127
  * @internal
159
128
  */
160
- dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
161
- ("production" !== process.env.NODE_ENV ? invariant(
162
- ExecutionEnvironment.canUseDOM,
163
- 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
164
- 'worker thread. Make sure `window` and `document` are available ' +
165
- 'globally before requiring React when unit testing or use ' +
166
- 'React.renderToString for server rendering.'
167
- ) : invariant(ExecutionEnvironment.canUseDOM));
168
- ("production" !== process.env.NODE_ENV ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
169
- ("production" !== process.env.NODE_ENV ? invariant(
170
- oldChild.tagName.toLowerCase() !== 'html',
171
- 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
172
- '<html> node. This is because browser quirks make this unreliable ' +
173
- 'and/or slow. If you want to render to the root you must use ' +
174
- 'server rendering. See React.renderToString().'
175
- ) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
129
+ dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
130
+ !ExecutionEnvironment.canUseDOM ? 'production' !== process.env.NODE_ENV ? 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 ' + 'React.renderToString for server rendering.') : invariant(false) : undefined;
131
+ !markup ? 'production' !== process.env.NODE_ENV ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
132
+ !(oldChild.tagName.toLowerCase() !== 'html') ? 'production' !== process.env.NODE_ENV ? 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 React.renderToString().') : invariant(false) : undefined;
176
133
 
177
134
  var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
178
135
  oldChild.parentNode.replaceChild(newChild, oldChild);
@@ -180,4 +137,4 @@ var Danger = {
180
137
 
181
138
  };
182
139
 
183
- module.exports = Danger;
140
+ module.exports = Danger;
@@ -22,16 +22,6 @@ var keyOf = require("./keyOf");
22
22
  * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
23
23
  * preventing default on events is convenient in `SimpleEventPlugin` handlers.
24
24
  */
25
- var DefaultEventPluginOrder = [
26
- keyOf({ResponderEventPlugin: null}),
27
- keyOf({SimpleEventPlugin: null}),
28
- keyOf({TapEventPlugin: null}),
29
- keyOf({EnterLeaveEventPlugin: null}),
30
- keyOf({ChangeEventPlugin: null}),
31
- keyOf({SelectEventPlugin: null}),
32
- keyOf({BeforeInputEventPlugin: null}),
33
- keyOf({AnalyticsEventPlugin: null}),
34
- keyOf({MobileSafariClickEventPlugin: null})
35
- ];
25
+ var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null }), keyOf({ AnalyticsEventPlugin: null })];
36
26
 
37
- module.exports = DefaultEventPluginOrder;
27
+ module.exports = DefaultEventPluginOrder;
@@ -24,18 +24,12 @@ var getFirstReactDOM = ReactMount.getFirstReactDOM;
24
24
 
25
25
  var eventTypes = {
26
26
  mouseEnter: {
27
- registrationName: keyOf({onMouseEnter: null}),
28
- dependencies: [
29
- topLevelTypes.topMouseOut,
30
- topLevelTypes.topMouseOver
31
- ]
27
+ registrationName: keyOf({ onMouseEnter: null }),
28
+ dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
32
29
  },
33
30
  mouseLeave: {
34
- registrationName: keyOf({onMouseLeave: null}),
35
- dependencies: [
36
- topLevelTypes.topMouseOut,
37
- topLevelTypes.topMouseOver
38
- ]
31
+ registrationName: keyOf({ onMouseLeave: null }),
32
+ dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
39
33
  }
40
34
  };
41
35
 
@@ -59,17 +53,11 @@ var EnterLeaveEventPlugin = {
59
53
  * @return {*} An accumulation of synthetic events.
60
54
  * @see {EventPluginHub.extractEvents}
61
55
  */
62
- extractEvents: function(
63
- topLevelType,
64
- topLevelTarget,
65
- topLevelTargetID,
66
- nativeEvent) {
67
- if (topLevelType === topLevelTypes.topMouseOver &&
68
- (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
56
+ extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
57
+ if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
69
58
  return null;
70
59
  }
71
- if (topLevelType !== topLevelTypes.topMouseOut &&
72
- topLevelType !== topLevelTypes.topMouseOver) {
60
+ if (topLevelType !== topLevelTypes.topMouseOut && topLevelType !== topLevelTypes.topMouseOver) {
73
61
  // Must not be a mouse in or mouse out - ignoring.
74
62
  return null;
75
63
  }
@@ -91,9 +79,7 @@ var EnterLeaveEventPlugin = {
91
79
  var from, to;
92
80
  if (topLevelType === topLevelTypes.topMouseOut) {
93
81
  from = topLevelTarget;
94
- to =
95
- getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
96
- win;
82
+ to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) || win;
97
83
  } else {
98
84
  from = win;
99
85
  to = topLevelTarget;
@@ -107,20 +93,12 @@ var EnterLeaveEventPlugin = {
107
93
  var fromID = from ? ReactMount.getID(from) : '';
108
94
  var toID = to ? ReactMount.getID(to) : '';
109
95
 
110
- var leave = SyntheticMouseEvent.getPooled(
111
- eventTypes.mouseLeave,
112
- fromID,
113
- nativeEvent
114
- );
96
+ var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget);
115
97
  leave.type = 'mouseleave';
116
98
  leave.target = from;
117
99
  leave.relatedTarget = to;
118
100
 
119
- var enter = SyntheticMouseEvent.getPooled(
120
- eventTypes.mouseEnter,
121
- toID,
122
- nativeEvent
123
- );
101
+ var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, toID, nativeEvent, nativeEventTarget);
124
102
  enter.type = 'mouseenter';
125
103
  enter.target = to;
126
104
  enter.relatedTarget = from;
@@ -135,4 +113,4 @@ var EnterLeaveEventPlugin = {
135
113
 
136
114
  };
137
115
 
138
- module.exports = EnterLeaveEventPlugin;
116
+ module.exports = EnterLeaveEventPlugin;