react 0.10.0 → 0.11.2

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 +20344 -0
  3. package/dist/react-with-addons.js +20276 -0
  4. package/dist/react-with-addons.min.js +22 -0
  5. package/dist/react.js +18484 -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} +42 -49
  23. package/lib/LinkedValueUtils.js +21 -22
  24. package/lib/LocalEventTrapMixin.js +52 -0
  25. package/lib/React.js +57 -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 +222 -384
  35. package/lib/ReactDOM.js +22 -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 +251 -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 +85 -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
@@ -22,6 +22,8 @@
22
22
  var SyntheticUIEvent = require("./SyntheticUIEvent");
23
23
  var ViewportMetrics = require("./ViewportMetrics");
24
24
 
25
+ var getEventModifierState = require("./getEventModifierState");
26
+
25
27
  /**
26
28
  * @interface MouseEvent
27
29
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
@@ -35,6 +37,7 @@ var MouseEventInterface = {
35
37
  shiftKey: null,
36
38
  altKey: null,
37
39
  metaKey: null,
40
+ getModifierState: getEventModifierState,
38
41
  button: function(event) {
39
42
  // Webkit, Firefox, IE9+
40
43
  // which: 1 2 3
@@ -21,6 +21,8 @@
21
21
 
22
22
  var SyntheticUIEvent = require("./SyntheticUIEvent");
23
23
 
24
+ var getEventModifierState = require("./getEventModifierState");
25
+
24
26
  /**
25
27
  * @interface TouchEvent
26
28
  * @see http://www.w3.org/TR/touch-events/
@@ -32,7 +34,8 @@ var TouchEventInterface = {
32
34
  altKey: null,
33
35
  metaKey: null,
34
36
  ctrlKey: null,
35
- shiftKey: null
37
+ shiftKey: null,
38
+ getModifierState: getEventModifierState
36
39
  };
37
40
 
38
41
  /**
@@ -21,13 +21,35 @@
21
21
 
22
22
  var SyntheticEvent = require("./SyntheticEvent");
23
23
 
24
+ var getEventTarget = require("./getEventTarget");
25
+
24
26
  /**
25
27
  * @interface UIEvent
26
28
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
27
29
  */
28
30
  var UIEventInterface = {
29
- view: null,
30
- detail: null
31
+ view: function(event) {
32
+ if (event.view) {
33
+ return event.view;
34
+ }
35
+
36
+ var target = getEventTarget(event);
37
+ if (target != null && target.window === target) {
38
+ // target is a window object
39
+ return target;
40
+ }
41
+
42
+ var doc = target.ownerDocument;
43
+ // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
44
+ if (doc) {
45
+ return doc.defaultView || doc.parentWindow;
46
+ } else {
47
+ return window;
48
+ }
49
+ },
50
+ detail: function(event) {
51
+ return event.detail || 0;
52
+ }
31
53
  };
32
54
 
33
55
  /**
@@ -57,9 +57,6 @@ var invariant = require("./invariant");
57
57
  * +-----------------------------------------+
58
58
  * </pre>
59
59
  *
60
- * Bonus:
61
- * - Reports timing metrics by method name and wrapper index.
62
- *
63
60
  * Use cases:
64
61
  * - Preserving the input selection ranges before/after reconciliation.
65
62
  * Restoring selection even in the event of an unexpected error.
@@ -99,20 +96,6 @@ var Mixin = {
99
96
  } else {
100
97
  this.wrapperInitData.length = 0;
101
98
  }
102
- if (!this.timingMetrics) {
103
- this.timingMetrics = {};
104
- }
105
- this.timingMetrics.methodInvocationTime = 0;
106
- if (!this.timingMetrics.wrapperInitTimes) {
107
- this.timingMetrics.wrapperInitTimes = [];
108
- } else {
109
- this.timingMetrics.wrapperInitTimes.length = 0;
110
- }
111
- if (!this.timingMetrics.wrapperCloseTimes) {
112
- this.timingMetrics.wrapperCloseTimes = [];
113
- } else {
114
- this.timingMetrics.wrapperCloseTimes.length = 0;
115
- }
116
99
  this._isInTransaction = false;
117
100
  },
118
101
 
@@ -145,7 +128,6 @@ var Mixin = {
145
128
  'Transaction.perform(...): Cannot initialize a transaction when there ' +
146
129
  'is already an outstanding transaction.'
147
130
  ) : invariant(!this.isInTransaction()));
148
- var memberStart = Date.now();
149
131
  var errorThrown;
150
132
  var ret;
151
133
  try {
@@ -159,8 +141,6 @@ var Mixin = {
159
141
  ret = method.call(scope, a, b, c, d, e, f);
160
142
  errorThrown = false;
161
143
  } finally {
162
- var memberEnd = Date.now();
163
- this.methodInvocationTime += (memberEnd - memberStart);
164
144
  try {
165
145
  if (errorThrown) {
166
146
  // If `method` throws, prefer to show that stack trace over any thrown
@@ -183,9 +163,7 @@ var Mixin = {
183
163
 
184
164
  initializeAll: function(startIndex) {
185
165
  var transactionWrappers = this.transactionWrappers;
186
- var wrapperInitTimes = this.timingMetrics.wrapperInitTimes;
187
166
  for (var i = startIndex; i < transactionWrappers.length; i++) {
188
- var initStart = Date.now();
189
167
  var wrapper = transactionWrappers[i];
190
168
  try {
191
169
  // Catching errors makes debugging more difficult, so we start with the
@@ -197,10 +175,6 @@ var Mixin = {
197
175
  wrapper.initialize.call(this) :
198
176
  null;
199
177
  } finally {
200
- var curInitTime = wrapperInitTimes[i];
201
- var initEnd = Date.now();
202
- wrapperInitTimes[i] = (curInitTime || 0) + (initEnd - initStart);
203
-
204
178
  if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
205
179
  // The initializer for wrapper i threw an error; initialize the
206
180
  // remaining wrappers but silence any exceptions from them to ensure
@@ -226,10 +200,8 @@ var Mixin = {
226
200
  'Transaction.closeAll(): Cannot close transaction when none are open.'
227
201
  ) : invariant(this.isInTransaction()));
228
202
  var transactionWrappers = this.transactionWrappers;
229
- var wrapperCloseTimes = this.timingMetrics.wrapperCloseTimes;
230
203
  for (var i = startIndex; i < transactionWrappers.length; i++) {
231
204
  var wrapper = transactionWrappers[i];
232
- var closeStart = Date.now();
233
205
  var initData = this.wrapperInitData[i];
234
206
  var errorThrown;
235
207
  try {
@@ -243,10 +215,6 @@ var Mixin = {
243
215
  }
244
216
  errorThrown = false;
245
217
  } finally {
246
- var closeEnd = Date.now();
247
- var curCloseTime = wrapperCloseTimes[i];
248
- wrapperCloseTimes[i] = (curCloseTime || 0) + (closeEnd - closeStart);
249
-
250
218
  if (errorThrown) {
251
219
  // The closer for wrapper i threw an error; close the remaining
252
220
  // wrappers but silence any exceptions from them to ensure that the
@@ -53,7 +53,9 @@ function cloneWithProps(child, props) {
53
53
  newProps.children = child.props.children;
54
54
  }
55
55
 
56
- return child.constructor.ConvenienceConstructor(newProps);
56
+ // The current API doesn't retain _owner and _context, which is why this
57
+ // doesn't use ReactDescriptor.cloneAndReplaceProps.
58
+ return child.constructor(newProps);
57
59
  }
58
60
 
59
61
  module.exports = cloneWithProps;
@@ -38,7 +38,7 @@ var invariant = require("./invariant");
38
38
  function createFullPageComponent(componentClass) {
39
39
  var FullPageComponent = ReactCompositeComponent.createClass({
40
40
  displayName: 'ReactFullPageComponent' + (
41
- componentClass.componentConstructor.displayName || ''
41
+ componentClass.type.displayName || ''
42
42
  ),
43
43
 
44
44
  componentWillUnmount: function() {
@@ -21,16 +21,18 @@
21
21
 
22
22
  var CSSProperty = require("./CSSProperty");
23
23
 
24
+ var isUnitlessNumber = CSSProperty.isUnitlessNumber;
25
+
24
26
  /**
25
- * Convert a value into the proper css writable value. The `styleName` name
26
- * name should be logical (no hyphens), as specified
27
+ * Convert a value into the proper css writable value. The style name `name`
28
+ * should be logical (no hyphens), as specified
27
29
  * in `CSSProperty.isUnitlessNumber`.
28
30
  *
29
- * @param {string} styleName CSS property name such as `topMargin`.
31
+ * @param {string} name CSS property name such as `topMargin`.
30
32
  * @param {*} value CSS property value such as `10px`.
31
33
  * @return {string} Normalized style value with dimensions applied.
32
34
  */
33
- function dangerousStyleValue(styleName, value) {
35
+ function dangerousStyleValue(name, value) {
34
36
  // Note that we've removed escapeTextForBrowser() calls here since the
35
37
  // whole string will be escaped when the attribute is injected into
36
38
  // the markup. If you provide unsafe user data here they can inject
@@ -47,10 +49,14 @@ function dangerousStyleValue(styleName, value) {
47
49
  }
48
50
 
49
51
  var isNonNumeric = isNaN(value);
50
- if (isNonNumeric || value === 0 || CSSProperty.isUnitlessNumber[styleName]) {
52
+ if (isNonNumeric || value === 0 ||
53
+ isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
51
54
  return '' + value; // cast to string
52
55
  }
53
56
 
57
+ if (typeof value === 'string') {
58
+ value = value.trim();
59
+ }
54
60
  return value + 'px';
55
61
  }
56
62
 
@@ -24,11 +24,10 @@ var ESCAPE_LOOKUP = {
24
24
  ">": "&gt;",
25
25
  "<": "&lt;",
26
26
  "\"": "&quot;",
27
- "'": "&#x27;",
28
- "/": "&#x2f;"
27
+ "'": "&#x27;"
29
28
  };
30
29
 
31
- var ESCAPE_REGEX = /[&><"'\/]/g;
30
+ var ESCAPE_REGEX = /[&><"']/g;
32
31
 
33
32
  function escaper(match) {
34
33
  return ESCAPE_LOOKUP[match];
@@ -18,8 +18,8 @@
18
18
 
19
19
  "use strict";
20
20
 
21
- var invariant = require("./invariant");
22
21
  var traverseAllChildren = require("./traverseAllChildren");
22
+ var warning = require("./warning");
23
23
 
24
24
  /**
25
25
  * @param {function} traverseContext Context passed through traversal.
@@ -29,13 +29,15 @@ var traverseAllChildren = require("./traverseAllChildren");
29
29
  function flattenSingleChildIntoContext(traverseContext, child, name) {
30
30
  // We found a component instance.
31
31
  var result = traverseContext;
32
- ("production" !== process.env.NODE_ENV ? invariant(
33
- !result.hasOwnProperty(name),
34
- 'flattenChildren(...): Encountered two children with the same key, `%s`. ' +
35
- 'Children keys must be unique.',
32
+ var keyUnique = !result.hasOwnProperty(name);
33
+ ("production" !== process.env.NODE_ENV ? warning(
34
+ keyUnique,
35
+ 'flattenChildren(...): Encountered two children with the same key, ' +
36
+ '`%s`. Child keys must be unique; when two children share a key, only ' +
37
+ 'the first child will be used.',
36
38
  name
37
- ) : invariant(!result.hasOwnProperty(name)));
38
- if (child != null) {
39
+ ) : null);
40
+ if (keyUnique && child != null) {
39
41
  result[name] = child;
40
42
  }
41
43
  }
@@ -19,8 +19,10 @@
19
19
 
20
20
  "use strict";
21
21
 
22
+ var invariant = require("./invariant");
23
+
22
24
  /**
23
- * Normalization of deprecated HTML5 "key" values
25
+ * Normalization of deprecated HTML5 `key` values
24
26
  * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
25
27
  */
26
28
  var normalizeKey = {
@@ -39,7 +41,7 @@ var normalizeKey = {
39
41
  };
40
42
 
41
43
  /**
42
- * Translation from legacy "which/keyCode" to HTML5 "key"
44
+ * Translation from legacy `which`/`keyCode` to HTML5 `key`
43
45
  * Only special keys supported, all others depend on keyboard layout or browser
44
46
  * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
45
47
  */
@@ -77,9 +79,37 @@ var translateToKey = {
77
79
  * @return {string} Normalized `key` property.
78
80
  */
79
81
  function getEventKey(nativeEvent) {
80
- return 'key' in nativeEvent ?
81
- normalizeKey[nativeEvent.key] || nativeEvent.key :
82
- translateToKey[nativeEvent.which || nativeEvent.keyCode] || 'Unidentified';
82
+ if (nativeEvent.key) {
83
+ // Normalize inconsistent values reported by browsers due to
84
+ // implementations of a working draft specification.
85
+
86
+ // FireFox implements `key` but returns `MozPrintableKey` for all
87
+ // printable characters (normalized to `Unidentified`), ignore it.
88
+ var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
89
+ if (key !== 'Unidentified') {
90
+ return key;
91
+ }
92
+ }
93
+
94
+ // Browser does not implement `key`, polyfill as much of it as we can.
95
+ if (nativeEvent.type === 'keypress') {
96
+ // Create the character from the `charCode` ourselves and use as an almost
97
+ // perfect replacement.
98
+ var charCode = 'charCode' in nativeEvent ?
99
+ nativeEvent.charCode :
100
+ nativeEvent.keyCode;
101
+
102
+ // The enter-key is technically both printable and non-printable and can
103
+ // thus be captured by `keypress`, no other non-printable key should.
104
+ return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
105
+ }
106
+ if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
107
+ // While user keyboard layout determines the actual meaning of each
108
+ // `keyCode` value, almost all function keys have a universal value.
109
+ return translateToKey[nativeEvent.keyCode] || 'Unidentified';
110
+ }
111
+
112
+ ("production" !== process.env.NODE_ENV ? invariant(false, "Unexpected keyboard event type: %s", nativeEvent.type) : invariant(false));
83
113
  }
84
114
 
85
115
  module.exports = getEventKey;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright 2013 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule getEventModifierState
17
+ * @typechecks static-only
18
+ */
19
+
20
+ "use strict";
21
+
22
+ /**
23
+ * Translation from modifier key to the associated property in the event.
24
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
25
+ */
26
+
27
+ var modifierKeyToProp = {
28
+ 'Alt': 'altKey',
29
+ 'Control': 'ctrlKey',
30
+ 'Meta': 'metaKey',
31
+ 'Shift': 'shiftKey'
32
+ };
33
+
34
+ // IE8 does not implement getModifierState so we simply map it to the only
35
+ // modifier keys exposed by the event itself, does not support Lock-keys.
36
+ // Currently, all major browsers except Chrome seems to support Lock-keys.
37
+ function modifierStateGetter(keyArg) {
38
+ /*jshint validthis:true */
39
+ var syntheticEvent = this;
40
+ var nativeEvent = syntheticEvent.nativeEvent;
41
+ if (nativeEvent.getModifierState) {
42
+ return nativeEvent.getModifierState(keyArg);
43
+ }
44
+ var keyProp = modifierKeyToProp[keyArg];
45
+ return keyProp ? !!nativeEvent[keyProp] : false;
46
+ }
47
+
48
+ function getEventModifierState(nativeEvent) {
49
+ return modifierStateGetter;
50
+ }
51
+
52
+ module.exports = getEventModifierState;
@@ -37,6 +37,7 @@ var shouldWrap = {
37
37
  // they will be initialized in the wrong namespace (and will not display).
38
38
  'circle': true,
39
39
  'defs': true,
40
+ 'ellipse': true,
40
41
  'g': true,
41
42
  'line': true,
42
43
  'linearGradient': true,
@@ -78,6 +79,7 @@ var markupWrap = {
78
79
 
79
80
  'circle': svgWrap,
80
81
  'defs': svgWrap,
82
+ 'ellipse': svgWrap,
81
83
  'g': svgWrap,
82
84
  'line': svgWrap,
83
85
  'linearGradient': svgWrap,
@@ -32,7 +32,7 @@ function getTextContentAccessor() {
32
32
  if (!contentKey && ExecutionEnvironment.canUseDOM) {
33
33
  // Prefer textContent to innerText because many browsers support both but
34
34
  // SVG <text> elements don't support innerText even when <div> does.
35
- contentKey = 'textContent' in document.createElement('div') ?
35
+ contentKey = 'textContent' in document.documentElement ?
36
36
  'textContent' :
37
37
  'innerText';
38
38
  }
package/lib/hyphenate.js CHANGED
@@ -25,6 +25,9 @@ var _uppercasePattern = /([A-Z])/g;
25
25
  * > hyphenate('backgroundColor')
26
26
  * < "background-color"
27
27
  *
28
+ * For CSS style names, use `hyphenateStyleName` instead which works properly
29
+ * with all vendor prefixes, including `ms`.
30
+ *
28
31
  * @param {string} string
29
32
  * @return {string}
30
33
  */
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright 2013-2014 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule hyphenateStyleName
17
+ * @typechecks
18
+ */
19
+
20
+ "use strict";
21
+
22
+ var hyphenate = require("./hyphenate");
23
+
24
+ var msPattern = /^ms-/;
25
+
26
+ /**
27
+ * Hyphenates a camelcased CSS property name, for example:
28
+ *
29
+ * > hyphenate('backgroundColor')
30
+ * < "background-color"
31
+ * > hyphenate('MozTransition')
32
+ * < "-moz-transition"
33
+ * > hyphenate('msTransition')
34
+ * < "-ms-transition"
35
+ *
36
+ * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
37
+ * is converted to `-ms-`.
38
+ *
39
+ * @param {string} string
40
+ * @return {string}
41
+ */
42
+ function hyphenateStyleName(string) {
43
+ return hyphenate(string).replace(msPattern, '-ms-');
44
+ }
45
+
46
+ module.exports = hyphenateStyleName;