react 0.10.0 → 0.11.0-rc1

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 (104) hide show
  1. package/README.md +3 -0
  2. package/dist/JSXTransformer.js +13445 -0
  3. package/dist/react-with-addons.js +20226 -0
  4. package/dist/react-with-addons.min.js +22 -0
  5. package/dist/react.js +18434 -0
  6. package/dist/react.min.js +21 -0
  7. package/lib/BeforeInputEventPlugin.js +222 -0
  8. package/lib/CSSPropertyOperations.js +3 -3
  9. package/lib/{ReactMountReady.js → CallbackQueue.js} +32 -24
  10. package/lib/ChangeEventPlugin.js +1 -1
  11. package/lib/CompositionEventPlugin.js +5 -1
  12. package/lib/DOMChildrenOperations.js +21 -14
  13. package/lib/DOMProperty.js +45 -17
  14. package/lib/DOMPropertyOperations.js +22 -10
  15. package/lib/DefaultEventPluginOrder.js +1 -0
  16. package/lib/EventConstants.js +1 -0
  17. package/lib/EventListener.js +5 -2
  18. package/lib/EventPluginHub.js +0 -5
  19. package/lib/EventPluginRegistry.js +6 -4
  20. package/lib/EventPluginUtils.js +11 -1
  21. package/lib/ExecutionEnvironment.js +8 -2
  22. package/lib/{DefaultDOMPropertyConfig.js → HTMLDOMPropertyConfig.js} +38 -48
  23. package/lib/LinkedValueUtils.js +21 -22
  24. package/lib/LocalEventTrapMixin.js +52 -0
  25. package/lib/React.js +36 -3
  26. package/lib/ReactBrowserComponentMixin.js +4 -0
  27. package/lib/{ReactEventEmitter.js → ReactBrowserEventEmitter.js} +115 -94
  28. package/lib/ReactCSSTransitionGroup.js +2 -0
  29. package/lib/ReactCSSTransitionGroupChild.js +2 -5
  30. package/lib/ReactChildren.js +31 -10
  31. package/lib/ReactComponent.js +88 -237
  32. package/lib/ReactComponentBrowserEnvironment.js +3 -2
  33. package/lib/ReactComponentWithPureRenderMixin.js +54 -0
  34. package/lib/ReactCompositeComponent.js +213 -383
  35. package/lib/ReactDOM.js +20 -18
  36. package/lib/ReactDOMComponent.js +26 -24
  37. package/lib/ReactDOMForm.js +5 -13
  38. package/lib/ReactDOMIDOperations.js +2 -31
  39. package/lib/ReactDOMImg.js +5 -14
  40. package/lib/ReactDOMSelect.js +16 -15
  41. package/lib/ReactDOMSelection.js +35 -10
  42. package/lib/ReactDOMTextarea.js +2 -4
  43. package/lib/ReactDefaultBatchingStrategy.js +3 -3
  44. package/lib/ReactDefaultInjection.js +18 -15
  45. package/lib/ReactDefaultPerf.js +28 -11
  46. package/lib/ReactDefaultPerfAnalysis.js +4 -0
  47. package/lib/ReactDescriptor.js +243 -0
  48. package/lib/ReactDescriptorValidator.js +283 -0
  49. package/lib/ReactEmptyComponent.js +78 -0
  50. package/lib/ReactEventEmitterMixin.js +1 -3
  51. package/lib/ReactEventListener.js +189 -0
  52. package/lib/ReactInjection.js +4 -2
  53. package/lib/ReactLink.js +24 -0
  54. package/lib/ReactMount.js +51 -19
  55. package/lib/ReactMultiChild.js +9 -11
  56. package/lib/ReactPropTransferer.js +44 -29
  57. package/lib/ReactPropTypes.js +226 -242
  58. package/lib/ReactPutListenerQueue.js +2 -2
  59. package/lib/ReactReconcileTransaction.js +14 -14
  60. package/lib/ReactServerRendering.js +5 -5
  61. package/lib/ReactServerRenderingTransaction.js +4 -5
  62. package/lib/ReactTestUtils.js +39 -21
  63. package/lib/ReactTextComponent.js +8 -22
  64. package/lib/ReactTransitionChildMapping.js +2 -2
  65. package/lib/ReactTransitionEvents.js +19 -0
  66. package/lib/ReactTransitionGroup.js +9 -6
  67. package/lib/ReactUpdates.js +139 -22
  68. package/lib/ReactWithAddons.js +5 -2
  69. package/lib/SVGDOMPropertyConfig.js +97 -0
  70. package/lib/SimpleEventPlugin.js +7 -1
  71. package/lib/SyntheticInputEvent.js +52 -0
  72. package/lib/SyntheticKeyboardEvent.js +33 -4
  73. package/lib/SyntheticMouseEvent.js +3 -0
  74. package/lib/SyntheticTouchEvent.js +4 -1
  75. package/lib/SyntheticUIEvent.js +24 -2
  76. package/lib/Transaction.js +0 -32
  77. package/lib/cloneWithProps.js +3 -1
  78. package/lib/createFullPageComponent.js +1 -1
  79. package/lib/dangerousStyleValue.js +11 -5
  80. package/lib/escapeTextForBrowser.js +2 -3
  81. package/lib/flattenChildren.js +9 -7
  82. package/lib/getEventKey.js +35 -5
  83. package/lib/getEventModifierState.js +52 -0
  84. package/lib/getMarkupWrap.js +2 -0
  85. package/lib/getTextContentAccessor.js +1 -1
  86. package/lib/hyphenate.js +3 -0
  87. package/lib/hyphenateStyleName.js +46 -0
  88. package/lib/instantiateReactComponent.js +13 -21
  89. package/lib/invariant.js +17 -19
  90. package/lib/{objMap.js → mapObject.js} +8 -3
  91. package/lib/mergeHelpers.js +11 -0
  92. package/lib/mergeInto.js +3 -2
  93. package/lib/onlyChild.js +3 -3
  94. package/lib/performance.js +33 -0
  95. package/lib/performanceNow.js +5 -14
  96. package/lib/setInnerHTML.js +77 -0
  97. package/lib/shouldUpdateReactComponent.js +12 -29
  98. package/lib/toArray.js +1 -1
  99. package/lib/traverseAllChildren.js +7 -4
  100. package/lib/update.js +57 -45
  101. package/package.json +4 -3
  102. package/lib/ReactEventTopLevelCallback.js +0 -149
  103. package/lib/createObjectFrom.js +0 -61
  104. 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
  */
@@ -27,8 +27,10 @@ var warning = require("./warning");
27
27
 
28
28
  function shouldIgnoreValue(name, value) {
29
29
  return value == null ||
30
- DOMProperty.hasBooleanValue[name] && !value ||
31
- 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);
32
34
  }
33
35
 
34
36
  var processAttributeNameAndPrefix = memoizeStringOnly(function(name) {
@@ -45,7 +47,8 @@ if ("production" !== process.env.NODE_ENV) {
45
47
  var warnedProperties = {};
46
48
 
47
49
  var warnUnknownProperty = function(name) {
48
- if (reactProps[name] || warnedProperties[name]) {
50
+ if (reactProps.hasOwnProperty(name) && reactProps[name] ||
51
+ warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
49
52
  return;
50
53
  }
51
54
 
@@ -53,8 +56,13 @@ if ("production" !== process.env.NODE_ENV) {
53
56
  var lowerCasedName = name.toLowerCase();
54
57
 
55
58
  // data-* attributes should be lowercase; suggest the lowercase version
56
- var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ?
57
- 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
+ );
58
66
 
59
67
  // For now, only warn when we have a suggested correction. This prevents
60
68
  // logging too much when using transferPropsTo.
@@ -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);
@@ -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,7 +20,6 @@
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");
@@ -154,10 +153,6 @@ var EventPluginHub = {
154
153
  * @param {?function} listener The callback to store.
155
154
  */
156
155
  putListener: function(id, registrationName, listener) {
157
- ("production" !== process.env.NODE_ENV ? invariant(
158
- ExecutionEnvironment.canUseDOM,
159
- 'Cannot call putListener() in a non-DOM environment.'
160
- ) : invariant(ExecutionEnvironment.canUseDOM));
161
156
  ("production" !== process.env.NODE_ENV ? invariant(
162
157
  !listener || typeof listener === 'function',
163
158
  'Expected %s listener to be a function, instead got type %s',
@@ -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,21 +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,
117
143
  srcSet: null,
144
+ start: HAS_NUMERIC_VALUE,
118
145
  step: null,
119
146
  style: null,
120
147
  tabIndex: null,
121
148
  target: null,
122
149
  title: null,
123
150
  type: null,
151
+ useMap: null,
124
152
  value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
125
153
  width: MUST_USE_ATTRIBUTE,
126
154
  wmode: MUST_USE_ATTRIBUTE,
@@ -130,53 +158,15 @@ var DefaultDOMPropertyConfig = {
130
158
  */
131
159
  autoCapitalize: null, // Supported in Mobile Safari for keyboard hints
132
160
  autoCorrect: null, // Supported in Mobile Safari for keyboard hints
133
- property: null, // Supports OG in meta tags
134
-
135
- /**
136
- * SVG Properties
137
- */
138
- cx: MUST_USE_ATTRIBUTE,
139
- cy: MUST_USE_ATTRIBUTE,
140
- d: MUST_USE_ATTRIBUTE,
141
- fill: MUST_USE_ATTRIBUTE,
142
- fx: MUST_USE_ATTRIBUTE,
143
- fy: MUST_USE_ATTRIBUTE,
144
- gradientTransform: MUST_USE_ATTRIBUTE,
145
- gradientUnits: MUST_USE_ATTRIBUTE,
146
- offset: MUST_USE_ATTRIBUTE,
147
- points: MUST_USE_ATTRIBUTE,
148
- r: MUST_USE_ATTRIBUTE,
149
- rx: MUST_USE_ATTRIBUTE,
150
- ry: MUST_USE_ATTRIBUTE,
151
- spreadMethod: MUST_USE_ATTRIBUTE,
152
- stopColor: MUST_USE_ATTRIBUTE,
153
- stopOpacity: MUST_USE_ATTRIBUTE,
154
- stroke: MUST_USE_ATTRIBUTE,
155
- strokeLinecap: MUST_USE_ATTRIBUTE,
156
- strokeWidth: MUST_USE_ATTRIBUTE,
157
- textAnchor: MUST_USE_ATTRIBUTE,
158
- transform: MUST_USE_ATTRIBUTE,
159
- version: MUST_USE_ATTRIBUTE,
160
- viewBox: MUST_USE_ATTRIBUTE,
161
- x1: MUST_USE_ATTRIBUTE,
162
- x2: MUST_USE_ATTRIBUTE,
163
- x: MUST_USE_ATTRIBUTE,
164
- y1: MUST_USE_ATTRIBUTE,
165
- y2: MUST_USE_ATTRIBUTE,
166
- 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
167
165
  },
168
166
  DOMAttributeNames: {
169
167
  className: 'class',
170
- gradientTransform: 'gradientTransform',
171
- gradientUnits: 'gradientUnits',
172
168
  htmlFor: 'for',
173
- spreadMethod: 'spreadMethod',
174
- stopColor: 'stop-color',
175
- stopOpacity: 'stop-opacity',
176
- strokeLinecap: 'stroke-linecap',
177
- strokeWidth: 'stroke-width',
178
- textAnchor: 'text-anchor',
179
- viewBox: 'viewBox'
169
+ httpEquiv: 'http-equiv'
180
170
  },
181
171
  DOMPropertyNames: {
182
172
  autoCapitalize: 'autocapitalize',
@@ -193,4 +183,4 @@ var DefaultDOMPropertyConfig = {
193
183
  }
194
184
  };
195
185
 
196
- module.exports = DefaultDOMPropertyConfig;
186
+ module.exports = HTMLDOMPropertyConfig;