hyphenateStyleName.js.flow 890 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Copyright (c) 2013-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @providesModule hyphenateStyleName
  8. * @typechecks
  9. */
  10. 'use strict';
  11. const hyphenate = require('./hyphenate');
  12. const msPattern = /^ms-/;
  13. /**
  14. * Hyphenates a camelcased CSS property name, for example:
  15. *
  16. * > hyphenateStyleName('backgroundColor')
  17. * < "background-color"
  18. * > hyphenateStyleName('MozTransition')
  19. * < "-moz-transition"
  20. * > hyphenateStyleName('msTransition')
  21. * < "-ms-transition"
  22. *
  23. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  24. * is converted to `-ms-`.
  25. *
  26. * @param {string} string
  27. * @return {string}
  28. */
  29. function hyphenateStyleName(string) {
  30. return hyphenate(string).replace(msPattern, '-ms-');
  31. }
  32. module.exports = hyphenateStyleName;