react 0.9.0 → 0.11.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 (114) hide show
  1. package/README.md +3 -0
  2. package/dist/JSXTransformer.js +13448 -0
  3. package/dist/react-with-addons.js +20235 -0
  4. package/dist/react-with-addons.min.js +22 -0
  5. package/dist/react.js +18443 -0
  6. package/dist/react.min.js +21 -0
  7. package/lib/AutoFocusMixin.js +3 -1
  8. package/lib/BeforeInputEventPlugin.js +222 -0
  9. package/lib/CSSPropertyOperations.js +3 -3
  10. package/lib/{ReactMountReady.js → CallbackQueue.js} +32 -24
  11. package/lib/ChangeEventPlugin.js +1 -1
  12. package/lib/CompositionEventPlugin.js +5 -1
  13. package/lib/DOMChildrenOperations.js +33 -20
  14. package/lib/DOMProperty.js +51 -21
  15. package/lib/DOMPropertyOperations.js +28 -16
  16. package/lib/DefaultEventPluginOrder.js +1 -0
  17. package/lib/EventConstants.js +1 -0
  18. package/lib/EventListener.js +5 -2
  19. package/lib/EventPluginHub.js +2 -5
  20. package/lib/EventPluginRegistry.js +6 -4
  21. package/lib/EventPluginUtils.js +11 -1
  22. package/lib/ExecutionEnvironment.js +8 -2
  23. package/lib/{DefaultDOMPropertyConfig.js → HTMLDOMPropertyConfig.js} +41 -58
  24. package/lib/LinkedValueUtils.js +26 -28
  25. package/lib/LocalEventTrapMixin.js +52 -0
  26. package/lib/React.js +39 -3
  27. package/lib/ReactBrowserComponentMixin.js +46 -0
  28. package/lib/{ReactEventEmitter.js → ReactBrowserEventEmitter.js} +115 -94
  29. package/lib/ReactCSSTransitionGroup.js +12 -10
  30. package/lib/ReactCSSTransitionGroupChild.js +2 -5
  31. package/lib/ReactChildren.js +31 -10
  32. package/lib/ReactComponent.js +119 -223
  33. package/lib/ReactComponentBrowserEnvironment.js +3 -36
  34. package/lib/ReactComponentWithPureRenderMixin.js +54 -0
  35. package/lib/ReactCompositeComponent.js +249 -287
  36. package/lib/ReactDOM.js +25 -23
  37. package/lib/ReactDOMButton.js +2 -1
  38. package/lib/ReactDOMComponent.js +42 -23
  39. package/lib/ReactDOMForm.js +7 -12
  40. package/lib/ReactDOMIDOperations.js +2 -31
  41. package/lib/ReactDOMImg.js +7 -13
  42. package/lib/ReactDOMInput.js +2 -1
  43. package/lib/ReactDOMOption.js +11 -7
  44. package/lib/ReactDOMSelect.js +18 -16
  45. package/lib/ReactDOMSelection.js +35 -10
  46. package/lib/ReactDOMTextarea.js +9 -7
  47. package/lib/ReactDefaultBatchingStrategy.js +3 -3
  48. package/lib/ReactDefaultInjection.js +27 -14
  49. package/lib/ReactDefaultPerf.js +28 -11
  50. package/lib/ReactDefaultPerfAnalysis.js +4 -0
  51. package/lib/ReactDescriptor.js +251 -0
  52. package/lib/ReactDescriptorValidator.js +283 -0
  53. package/lib/ReactEmptyComponent.js +78 -0
  54. package/lib/ReactEventEmitterMixin.js +1 -3
  55. package/lib/ReactEventListener.js +189 -0
  56. package/lib/ReactInjection.js +8 -2
  57. package/lib/ReactInputSelection.js +2 -1
  58. package/lib/ReactLink.js +24 -0
  59. package/lib/ReactMount.js +61 -21
  60. package/lib/ReactMultiChild.js +18 -13
  61. package/lib/ReactOwner.js +6 -1
  62. package/lib/ReactPropTransferer.js +44 -29
  63. package/lib/ReactPropTypes.js +226 -242
  64. package/lib/ReactPutListenerQueue.js +2 -2
  65. package/lib/ReactReconcileTransaction.js +21 -20
  66. package/lib/ReactServerRendering.js +41 -11
  67. package/lib/ReactServerRenderingTransaction.js +115 -0
  68. package/lib/ReactTestUtils.js +39 -21
  69. package/lib/ReactTextComponent.js +21 -13
  70. package/lib/ReactTransitionChildMapping.js +2 -2
  71. package/lib/ReactTransitionEvents.js +19 -0
  72. package/lib/ReactTransitionGroup.js +9 -6
  73. package/lib/ReactUpdates.js +139 -22
  74. package/lib/ReactWithAddons.js +8 -3
  75. package/lib/SVGDOMPropertyConfig.js +97 -0
  76. package/lib/SimpleEventPlugin.js +7 -1
  77. package/lib/SyntheticInputEvent.js +52 -0
  78. package/lib/SyntheticKeyboardEvent.js +33 -4
  79. package/lib/SyntheticMouseEvent.js +3 -0
  80. package/lib/SyntheticTouchEvent.js +4 -1
  81. package/lib/SyntheticUIEvent.js +24 -2
  82. package/lib/Transaction.js +0 -32
  83. package/lib/cloneWithProps.js +10 -8
  84. package/lib/createFullPageComponent.js +1 -1
  85. package/lib/dangerousStyleValue.js +11 -5
  86. package/lib/{ReactComponentEnvironment.js → emptyObject.js} +6 -5
  87. package/lib/escapeTextForBrowser.js +2 -3
  88. package/lib/flattenChildren.js +9 -7
  89. package/lib/focusNode.js +33 -0
  90. package/lib/getEventKey.js +35 -5
  91. package/lib/getEventModifierState.js +52 -0
  92. package/lib/getMarkupWrap.js +2 -0
  93. package/lib/getTextContentAccessor.js +1 -1
  94. package/lib/hyphenate.js +3 -0
  95. package/lib/hyphenateStyleName.js +46 -0
  96. package/lib/instantiateReactComponent.js +62 -0
  97. package/lib/invariant.js +17 -19
  98. package/lib/isNode.js +1 -1
  99. package/lib/{objMap.js → mapObject.js} +8 -3
  100. package/lib/mergeHelpers.js +11 -0
  101. package/lib/mergeInto.js +3 -2
  102. package/lib/monitorCodeUse.js +37 -0
  103. package/lib/onlyChild.js +3 -3
  104. package/lib/performance.js +33 -0
  105. package/lib/performanceNow.js +5 -14
  106. package/lib/setInnerHTML.js +77 -0
  107. package/lib/shouldUpdateReactComponent.js +14 -28
  108. package/lib/toArray.js +1 -1
  109. package/lib/traverseAllChildren.js +9 -5
  110. package/lib/update.js +171 -0
  111. package/package.json +4 -3
  112. package/lib/ReactEventTopLevelCallback.js +0 -149
  113. package/lib/createObjectFrom.js +0 -61
  114. package/lib/objMapKeyVal.js +0 -47
@@ -32,7 +32,9 @@ var DOMPropertyInjection = {
32
32
  MUST_USE_PROPERTY: 0x2,
33
33
  HAS_SIDE_EFFECTS: 0x4,
34
34
  HAS_BOOLEAN_VALUE: 0x8,
35
- HAS_POSITIVE_NUMERIC_VALUE: 0x10,
35
+ HAS_NUMERIC_VALUE: 0x10,
36
+ HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
37
+ HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
36
38
 
37
39
  /**
38
40
  * Inject some specialized knowledge about the DOM. This takes a config object
@@ -73,32 +75,36 @@ var DOMPropertyInjection = {
73
75
 
74
76
  for (var propName in Properties) {
75
77
  ("production" !== process.env.NODE_ENV ? invariant(
76
- !DOMProperty.isStandardName[propName],
78
+ !DOMProperty.isStandardName.hasOwnProperty(propName),
77
79
  'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
78
80
  '\'%s\' which has already been injected. You may be accidentally ' +
79
81
  'injecting the same DOM property config twice, or you may be ' +
80
82
  'injecting two configs that have conflicting property names.',
81
83
  propName
82
- ) : invariant(!DOMProperty.isStandardName[propName]));
84
+ ) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
83
85
 
84
86
  DOMProperty.isStandardName[propName] = true;
85
87
 
86
88
  var lowerCased = propName.toLowerCase();
87
89
  DOMProperty.getPossibleStandardName[lowerCased] = propName;
88
90
 
89
- var attributeName = DOMAttributeNames[propName];
90
- if (attributeName) {
91
+ if (DOMAttributeNames.hasOwnProperty(propName)) {
92
+ var attributeName = DOMAttributeNames[propName];
91
93
  DOMProperty.getPossibleStandardName[attributeName] = propName;
94
+ DOMProperty.getAttributeName[propName] = attributeName;
95
+ } else {
96
+ DOMProperty.getAttributeName[propName] = lowerCased;
92
97
  }
93
98
 
94
- DOMProperty.getAttributeName[propName] = attributeName || lowerCased;
95
-
96
99
  DOMProperty.getPropertyName[propName] =
97
- DOMPropertyNames[propName] || propName;
98
-
99
- var mutationMethod = DOMMutationMethods[propName];
100
- if (mutationMethod) {
101
- DOMProperty.getMutationMethod[propName] = mutationMethod;
100
+ DOMPropertyNames.hasOwnProperty(propName) ?
101
+ DOMPropertyNames[propName] :
102
+ propName;
103
+
104
+ if (DOMMutationMethods.hasOwnProperty(propName)) {
105
+ DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
106
+ } else {
107
+ DOMProperty.getMutationMethod[propName] = null;
102
108
  }
103
109
 
104
110
  var propConfig = Properties[propName];
@@ -110,8 +116,12 @@ var DOMPropertyInjection = {
110
116
  propConfig & DOMPropertyInjection.HAS_SIDE_EFFECTS;
111
117
  DOMProperty.hasBooleanValue[propName] =
112
118
  propConfig & DOMPropertyInjection.HAS_BOOLEAN_VALUE;
119
+ DOMProperty.hasNumericValue[propName] =
120
+ propConfig & DOMPropertyInjection.HAS_NUMERIC_VALUE;
113
121
  DOMProperty.hasPositiveNumericValue[propName] =
114
122
  propConfig & DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE;
123
+ DOMProperty.hasOverloadedBooleanValue[propName] =
124
+ propConfig & DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE;
115
125
 
116
126
  ("production" !== process.env.NODE_ENV ? invariant(
117
127
  !DOMProperty.mustUseAttribute[propName] ||
@@ -128,12 +138,15 @@ var DOMPropertyInjection = {
128
138
  ) : invariant(DOMProperty.mustUseProperty[propName] ||
129
139
  !DOMProperty.hasSideEffects[propName]));
130
140
  ("production" !== process.env.NODE_ENV ? invariant(
131
- !DOMProperty.hasBooleanValue[propName] ||
132
- !DOMProperty.hasPositiveNumericValue[propName],
133
- 'DOMProperty: Cannot have both boolean and positive numeric value: %s',
141
+ !!DOMProperty.hasBooleanValue[propName] +
142
+ !!DOMProperty.hasNumericValue[propName] +
143
+ !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
144
+ 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
145
+ 'numeric value, but not a combination: %s',
134
146
  propName
135
- ) : invariant(!DOMProperty.hasBooleanValue[propName] ||
136
- !DOMProperty.hasPositiveNumericValue[propName]));
147
+ ) : invariant(!!DOMProperty.hasBooleanValue[propName] +
148
+ !!DOMProperty.hasNumericValue[propName] +
149
+ !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
137
150
  }
138
151
  }
139
152
  };
@@ -217,6 +230,13 @@ var DOMProperty = {
217
230
  */
218
231
  hasBooleanValue: {},
219
232
 
233
+ /**
234
+ * Whether the property must be numeric or parse as a
235
+ * numeric and should be removed when set to a falsey value.
236
+ * @type {Object}
237
+ */
238
+ hasNumericValue: {},
239
+
220
240
  /**
221
241
  * Whether the property must be positive numeric or parse as a positive
222
242
  * numeric and should be removed when set to a falsey value.
@@ -224,6 +244,14 @@ var DOMProperty = {
224
244
  */
225
245
  hasPositiveNumericValue: {},
226
246
 
247
+ /**
248
+ * Whether the property can be used as a flag as well as with a value. Removed
249
+ * when strictly equal to false; present without a value when strictly equal
250
+ * to true; present with a value otherwise.
251
+ * @type {Object}
252
+ */
253
+ hasOverloadedBooleanValue: {},
254
+
227
255
  /**
228
256
  * All of the isCustomAttribute() functions that have been injected.
229
257
  */
@@ -234,11 +262,13 @@ var DOMProperty = {
234
262
  * @method
235
263
  */
236
264
  isCustomAttribute: function(attributeName) {
237
- return DOMProperty._isCustomAttributeFunctions.some(
238
- function(isCustomAttributeFn) {
239
- return isCustomAttributeFn.call(null, attributeName);
265
+ for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
266
+ var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
267
+ if (isCustomAttributeFn(attributeName)) {
268
+ return true;
240
269
  }
241
- );
270
+ }
271
+ return false;
242
272
  },
243
273
 
244
274
  /**
@@ -23,11 +23,14 @@ var DOMProperty = require("./DOMProperty");
23
23
 
24
24
  var escapeTextForBrowser = require("./escapeTextForBrowser");
25
25
  var memoizeStringOnly = require("./memoizeStringOnly");
26
+ var warning = require("./warning");
26
27
 
27
28
  function shouldIgnoreValue(name, value) {
28
29
  return value == null ||
29
- DOMProperty.hasBooleanValue[name] && !value ||
30
- DOMProperty.hasPositiveNumericValue[name] && (isNaN(value) || value < 1);
30
+ (DOMProperty.hasBooleanValue[name] && !value) ||
31
+ (DOMProperty.hasNumericValue[name] && isNaN(value)) ||
32
+ (DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
33
+ (DOMProperty.hasOverloadedBooleanValue[name] && value === false);
31
34
  }
32
35
 
33
36
  var processAttributeNameAndPrefix = memoizeStringOnly(function(name) {
@@ -44,7 +47,8 @@ if ("production" !== process.env.NODE_ENV) {
44
47
  var warnedProperties = {};
45
48
 
46
49
  var warnUnknownProperty = function(name) {
47
- if (reactProps[name] || warnedProperties[name]) {
50
+ if (reactProps.hasOwnProperty(name) && reactProps[name] ||
51
+ warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
48
52
  return;
49
53
  }
50
54
 
@@ -52,16 +56,20 @@ if ("production" !== process.env.NODE_ENV) {
52
56
  var lowerCasedName = name.toLowerCase();
53
57
 
54
58
  // data-* attributes should be lowercase; suggest the lowercase version
55
- var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ?
56
- lowerCasedName : DOMProperty.getPossibleStandardName[lowerCasedName];
59
+ var standardName = (
60
+ DOMProperty.isCustomAttribute(lowerCasedName) ?
61
+ lowerCasedName :
62
+ DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
63
+ DOMProperty.getPossibleStandardName[lowerCasedName] :
64
+ null
65
+ );
57
66
 
58
67
  // For now, only warn when we have a suggested correction. This prevents
59
68
  // logging too much when using transferPropsTo.
60
- if (standardName != null) {
61
- console.warn(
62
- 'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
63
- );
64
- }
69
+ ("production" !== process.env.NODE_ENV ? warning(
70
+ standardName == null,
71
+ 'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
72
+ ) : null);
65
73
 
66
74
  };
67
75
  }
@@ -90,12 +98,14 @@ var DOMPropertyOperations = {
90
98
  * @return {?string} Markup string, or null if the property was invalid.
91
99
  */
92
100
  createMarkupForProperty: function(name, value) {
93
- if (DOMProperty.isStandardName[name]) {
101
+ if (DOMProperty.isStandardName.hasOwnProperty(name) &&
102
+ DOMProperty.isStandardName[name]) {
94
103
  if (shouldIgnoreValue(name, value)) {
95
104
  return '';
96
105
  }
97
106
  var attributeName = DOMProperty.getAttributeName[name];
98
- if (DOMProperty.hasBooleanValue[name]) {
107
+ if (DOMProperty.hasBooleanValue[name] ||
108
+ (DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
99
109
  return escapeTextForBrowser(attributeName);
100
110
  }
101
111
  return processAttributeNameAndPrefix(attributeName) +
@@ -120,7 +130,8 @@ var DOMPropertyOperations = {
120
130
  * @param {*} value
121
131
  */
122
132
  setValueForProperty: function(node, name, value) {
123
- if (DOMProperty.isStandardName[name]) {
133
+ if (DOMProperty.isStandardName.hasOwnProperty(name) &&
134
+ DOMProperty.isStandardName[name]) {
124
135
  var mutationMethod = DOMProperty.getMutationMethod[name];
125
136
  if (mutationMethod) {
126
137
  mutationMethod(node, value);
@@ -136,7 +147,7 @@ var DOMPropertyOperations = {
136
147
  }
137
148
  } else if (DOMProperty.isCustomAttribute(name)) {
138
149
  if (value == null) {
139
- node.removeAttribute(DOMProperty.getAttributeName[name]);
150
+ node.removeAttribute(name);
140
151
  } else {
141
152
  node.setAttribute(name, '' + value);
142
153
  }
@@ -152,7 +163,8 @@ var DOMPropertyOperations = {
152
163
  * @param {string} name
153
164
  */
154
165
  deleteValueForProperty: function(node, name) {
155
- if (DOMProperty.isStandardName[name]) {
166
+ if (DOMProperty.isStandardName.hasOwnProperty(name) &&
167
+ DOMProperty.isStandardName[name]) {
156
168
  var mutationMethod = DOMProperty.getMutationMethod[name];
157
169
  if (mutationMethod) {
158
170
  mutationMethod(node, undefined);
@@ -162,7 +174,7 @@ var DOMPropertyOperations = {
162
174
  var propName = DOMProperty.getPropertyName[name];
163
175
  var defaultValue = DOMProperty.getDefaultValueForProperty(
164
176
  node.nodeName,
165
- name
177
+ propName
166
178
  );
167
179
  if (!DOMProperty.hasSideEffects[name] ||
168
180
  node[propName] !== defaultValue) {
@@ -37,6 +37,7 @@ var DefaultEventPluginOrder = [
37
37
  keyOf({ChangeEventPlugin: null}),
38
38
  keyOf({SelectEventPlugin: null}),
39
39
  keyOf({CompositionEventPlugin: null}),
40
+ keyOf({BeforeInputEventPlugin: null}),
40
41
  keyOf({AnalyticsEventPlugin: null}),
41
42
  keyOf({MobileSafariClickEventPlugin: null})
42
43
  ];
@@ -61,6 +61,7 @@ var topLevelTypes = keyMirror({
61
61
  topScroll: null,
62
62
  topSelectionChange: null,
63
63
  topSubmit: null,
64
+ topTextInput: null,
64
65
  topTouchCancel: null,
65
66
  topTouchEnd: null,
66
67
  topTouchMove: null,
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * @providesModule EventListener
3
+ * @typechecks
3
4
  */
4
5
 
5
6
  var emptyFunction = require("./emptyFunction");
@@ -29,7 +30,7 @@ var EventListener = {
29
30
  target.attachEvent('on' + eventType, callback);
30
31
  return {
31
32
  remove: function() {
32
- target.detachEvent(eventType, callback);
33
+ target.detachEvent('on' + eventType, callback);
33
34
  }
34
35
  };
35
36
  }
@@ -63,7 +64,9 @@ var EventListener = {
63
64
  }
64
65
  };
65
66
  }
66
- }
67
+ },
68
+
69
+ registerDefault: function() {}
67
70
  };
68
71
 
69
72
  module.exports = EventListener;
@@ -20,12 +20,12 @@
20
20
 
21
21
  var EventPluginRegistry = require("./EventPluginRegistry");
22
22
  var EventPluginUtils = require("./EventPluginUtils");
23
- var ExecutionEnvironment = require("./ExecutionEnvironment");
24
23
 
25
24
  var accumulate = require("./accumulate");
26
25
  var forEachAccumulated = require("./forEachAccumulated");
27
26
  var invariant = require("./invariant");
28
27
  var isEventSupported = require("./isEventSupported");
28
+ var monitorCodeUse = require("./monitorCodeUse");
29
29
 
30
30
  /**
31
31
  * Internal store for event listeners
@@ -153,10 +153,6 @@ var EventPluginHub = {
153
153
  * @param {?function} listener The callback to store.
154
154
  */
155
155
  putListener: function(id, registrationName, listener) {
156
- ("production" !== process.env.NODE_ENV ? invariant(
157
- ExecutionEnvironment.canUseDOM,
158
- 'Cannot call putListener() in a non-DOM environment.'
159
- ) : invariant(ExecutionEnvironment.canUseDOM));
160
156
  ("production" !== process.env.NODE_ENV ? invariant(
161
157
  !listener || typeof listener === 'function',
162
158
  'Expected %s listener to be a function, instead got type %s',
@@ -168,6 +164,7 @@ var EventPluginHub = {
168
164
  // bubble.
169
165
  if (registrationName === 'onScroll' &&
170
166
  !isEventSupported('scroll', true)) {
167
+ monitorCodeUse('react_no_scroll_event');
171
168
  console.warn('This browser doesn\'t support the `onScroll` event');
172
169
  }
173
170
  }
@@ -90,11 +90,11 @@ function recomputePluginOrdering() {
90
90
  */
91
91
  function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
92
92
  ("production" !== process.env.NODE_ENV ? invariant(
93
- !EventPluginRegistry.eventNameDispatchConfigs[eventName],
93
+ !EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
94
94
  'EventPluginHub: More than one plugin attempted to publish the same ' +
95
95
  'event name, `%s`.',
96
96
  eventName
97
- ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs[eventName]));
97
+ ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
98
98
  EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
99
99
 
100
100
  var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
@@ -180,7 +180,8 @@ var EventPluginRegistry = {
180
180
  injectEventPluginOrder: function(InjectedEventPluginOrder) {
181
181
  ("production" !== process.env.NODE_ENV ? invariant(
182
182
  !EventPluginOrder,
183
- 'EventPluginRegistry: Cannot inject event plugin ordering more than once.'
183
+ 'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
184
+ 'once. You are likely trying to load more than one copy of React.'
184
185
  ) : invariant(!EventPluginOrder));
185
186
  // Clone the ordering so it cannot be dynamically mutated.
186
187
  EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
@@ -204,7 +205,8 @@ var EventPluginRegistry = {
204
205
  continue;
205
206
  }
206
207
  var PluginModule = injectedNamesToPlugins[pluginName];
207
- if (namesToPlugins[pluginName] !== PluginModule) {
208
+ if (!namesToPlugins.hasOwnProperty(pluginName) ||
209
+ namesToPlugins[pluginName] !== PluginModule) {
208
210
  ("production" !== process.env.NODE_ENV ? invariant(
209
211
  !namesToPlugins[pluginName],
210
212
  'EventPluginRegistry: Cannot inject two different event plugins ' +
@@ -135,7 +135,7 @@ function executeDispatchesInOrder(event, executeDispatch) {
135
135
  * @return id of the first dispatch execution who's listener returns true, or
136
136
  * null if no listener returned true.
137
137
  */
138
- function executeDispatchesInOrderStopAtTrue(event) {
138
+ function executeDispatchesInOrderStopAtTrueImpl(event) {
139
139
  var dispatchListeners = event._dispatchListeners;
140
140
  var dispatchIDs = event._dispatchIDs;
141
141
  if ("production" !== process.env.NODE_ENV) {
@@ -159,6 +159,16 @@ function executeDispatchesInOrderStopAtTrue(event) {
159
159
  return null;
160
160
  }
161
161
 
162
+ /**
163
+ * @see executeDispatchesInOrderStopAtTrueImpl
164
+ */
165
+ function executeDispatchesInOrderStopAtTrue(event) {
166
+ var ret = executeDispatchesInOrderStopAtTrueImpl(event);
167
+ event._dispatchIDs = null;
168
+ event._dispatchListeners = null;
169
+ return ret;
170
+ }
171
+
162
172
  /**
163
173
  * Execution of a "direct" dispatch - there must be at most one dispatch
164
174
  * accumulated on the event or it is considered an error. It doesn't really make
@@ -20,7 +20,11 @@
20
20
 
21
21
  "use strict";
22
22
 
23
- var canUseDOM = typeof window !== 'undefined';
23
+ var canUseDOM = !!(
24
+ typeof window !== 'undefined' &&
25
+ window.document &&
26
+ window.document.createElement
27
+ );
24
28
 
25
29
  /**
26
30
  * Simple, lightweight module assisting with the detection and context of
@@ -35,7 +39,9 @@ var ExecutionEnvironment = {
35
39
  canUseWorkers: typeof Worker !== 'undefined',
36
40
 
37
41
  canUseEventListeners:
38
- canUseDOM && (window.addEventListener || window.attachEvent),
42
+ canUseDOM && !!(window.addEventListener || window.attachEvent),
43
+
44
+ canUseViewport: canUseDOM && !!window.screen,
39
45
 
40
46
  isInWorker: !canUseDOM // For now, this is true - might change in the future.
41
47
 
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  *
16
- * @providesModule DefaultDOMPropertyConfig
16
+ * @providesModule HTMLDOMPropertyConfig
17
17
  */
18
18
 
19
19
  /*jslint bitwise: true*/
@@ -21,15 +21,33 @@
21
21
  "use strict";
22
22
 
23
23
  var DOMProperty = require("./DOMProperty");
24
+ var ExecutionEnvironment = require("./ExecutionEnvironment");
24
25
 
25
26
  var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
26
27
  var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
27
28
  var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
28
29
  var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
30
+ var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
29
31
  var HAS_POSITIVE_NUMERIC_VALUE =
30
32
  DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
33
+ var HAS_OVERLOADED_BOOLEAN_VALUE =
34
+ DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
31
35
 
32
- var DefaultDOMPropertyConfig = {
36
+ var hasSVG;
37
+ if (ExecutionEnvironment.canUseDOM) {
38
+ var implementation = document.implementation;
39
+ hasSVG = (
40
+ implementation &&
41
+ implementation.hasFeature &&
42
+ implementation.hasFeature(
43
+ 'http://www.w3.org/TR/SVG11/feature#BasicStructure',
44
+ '1.1'
45
+ )
46
+ );
47
+ }
48
+
49
+
50
+ var HTMLDOMPropertyConfig = {
33
51
  isCustomAttribute: RegExp.prototype.test.bind(
34
52
  /^(data|aria)-[a-z_][a-z\d_.\-]*$/
35
53
  ),
@@ -52,20 +70,26 @@ var DefaultDOMPropertyConfig = {
52
70
  cellSpacing: null,
53
71
  charSet: MUST_USE_ATTRIBUTE,
54
72
  checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
55
- className: MUST_USE_PROPERTY,
73
+ // To set className on SVG elements, it's necessary to use .setAttribute;
74
+ // this works on HTML elements too in all browsers except IE8. Conveniently,
75
+ // IE8 doesn't support SVG and so we can simply use the attribute in
76
+ // browsers that support SVG and the property in browsers that don't,
77
+ // regardless of whether the element is HTML or SVG.
78
+ className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
56
79
  cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
57
80
  colSpan: null,
58
81
  content: null,
59
82
  contentEditable: null,
60
83
  contextMenu: MUST_USE_ATTRIBUTE,
61
84
  controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
85
+ coords: null,
62
86
  crossOrigin: null,
63
87
  data: null, // For `<object />` acts as `src`.
64
88
  dateTime: MUST_USE_ATTRIBUTE,
65
89
  defer: HAS_BOOLEAN_VALUE,
66
90
  dir: null,
67
91
  disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
68
- download: null,
92
+ download: HAS_OVERLOADED_BOOLEAN_VALUE,
69
93
  draggable: null,
70
94
  encType: null,
71
95
  form: MUST_USE_ATTRIBUTE,
@@ -106,20 +130,25 @@ var DefaultDOMPropertyConfig = {
106
130
  sandbox: null,
107
131
  scope: null,
108
132
  scrollLeft: MUST_USE_PROPERTY,
133
+ scrolling: null,
109
134
  scrollTop: MUST_USE_PROPERTY,
110
135
  seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
111
136
  selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
137
+ shape: null,
112
138
  size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
113
139
  span: HAS_POSITIVE_NUMERIC_VALUE,
114
140
  spellCheck: null,
115
141
  src: null,
116
142
  srcDoc: MUST_USE_PROPERTY,
143
+ srcSet: null,
144
+ start: HAS_NUMERIC_VALUE,
117
145
  step: null,
118
146
  style: null,
119
147
  tabIndex: null,
120
148
  target: null,
121
149
  title: null,
122
150
  type: null,
151
+ useMap: null,
123
152
  value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
124
153
  width: MUST_USE_ATTRIBUTE,
125
154
  wmode: MUST_USE_ATTRIBUTE,
@@ -129,51 +158,15 @@ var DefaultDOMPropertyConfig = {
129
158
  */
130
159
  autoCapitalize: null, // Supported in Mobile Safari for keyboard hints
131
160
  autoCorrect: null, // Supported in Mobile Safari for keyboard hints
132
- property: null, // Supports OG in meta tags
133
-
134
- /**
135
- * SVG Properties
136
- */
137
- cx: MUST_USE_ATTRIBUTE,
138
- cy: MUST_USE_ATTRIBUTE,
139
- d: MUST_USE_ATTRIBUTE,
140
- fill: MUST_USE_ATTRIBUTE,
141
- fx: MUST_USE_ATTRIBUTE,
142
- fy: MUST_USE_ATTRIBUTE,
143
- gradientTransform: MUST_USE_ATTRIBUTE,
144
- gradientUnits: MUST_USE_ATTRIBUTE,
145
- offset: MUST_USE_ATTRIBUTE,
146
- points: MUST_USE_ATTRIBUTE,
147
- r: MUST_USE_ATTRIBUTE,
148
- rx: MUST_USE_ATTRIBUTE,
149
- ry: MUST_USE_ATTRIBUTE,
150
- spreadMethod: MUST_USE_ATTRIBUTE,
151
- stopColor: MUST_USE_ATTRIBUTE,
152
- stopOpacity: MUST_USE_ATTRIBUTE,
153
- stroke: MUST_USE_ATTRIBUTE,
154
- strokeLinecap: MUST_USE_ATTRIBUTE,
155
- strokeWidth: MUST_USE_ATTRIBUTE,
156
- transform: MUST_USE_ATTRIBUTE,
157
- version: MUST_USE_ATTRIBUTE,
158
- viewBox: MUST_USE_ATTRIBUTE,
159
- x1: MUST_USE_ATTRIBUTE,
160
- x2: MUST_USE_ATTRIBUTE,
161
- x: MUST_USE_ATTRIBUTE,
162
- y1: MUST_USE_ATTRIBUTE,
163
- y2: MUST_USE_ATTRIBUTE,
164
- y: MUST_USE_ATTRIBUTE
161
+ itemProp: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html
162
+ itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, // Microdata: http://schema.org/docs/gs.html
163
+ itemType: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html
164
+ property: null // Supports OG in meta tags
165
165
  },
166
166
  DOMAttributeNames: {
167
167
  className: 'class',
168
- gradientTransform: 'gradientTransform',
169
- gradientUnits: 'gradientUnits',
170
168
  htmlFor: 'for',
171
- spreadMethod: 'spreadMethod',
172
- stopColor: 'stop-color',
173
- stopOpacity: 'stop-opacity',
174
- strokeLinecap: 'stroke-linecap',
175
- strokeWidth: 'stroke-width',
176
- viewBox: 'viewBox'
169
+ httpEquiv: 'http-equiv'
177
170
  },
178
171
  DOMPropertyNames: {
179
172
  autoCapitalize: 'autocapitalize',
@@ -185,19 +178,9 @@ var DefaultDOMPropertyConfig = {
185
178
  hrefLang: 'hreflang',
186
179
  radioGroup: 'radiogroup',
187
180
  spellCheck: 'spellcheck',
188
- srcDoc: 'srcdoc'
189
- },
190
- DOMMutationMethods: {
191
- /**
192
- * Setting `className` to null may cause it to be set to the string "null".
193
- *
194
- * @param {DOMElement} node
195
- * @param {*} value
196
- */
197
- className: function(node, value) {
198
- node.className = value || '';
199
- }
181
+ srcDoc: 'srcdoc',
182
+ srcSet: 'srcset'
200
183
  }
201
184
  };
202
185
 
203
- module.exports = DefaultDOMPropertyConfig;
186
+ module.exports = HTMLDOMPropertyConfig;