camelizeStyleName.js.flow 916 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 camelizeStyleName
  8. * @typechecks
  9. */
  10. 'use strict';
  11. const camelize = require('./camelize');
  12. const msPattern = /^-ms-/;
  13. /**
  14. * Camelcases a hyphenated CSS property name, for example:
  15. *
  16. * > camelizeStyleName('background-color')
  17. * < "backgroundColor"
  18. * > camelizeStyleName('-moz-transition')
  19. * < "MozTransition"
  20. * > camelizeStyleName('-ms-transition')
  21. * < "msTransition"
  22. *
  23. * As Andi Smith suggests
  24. * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  25. * is converted to lowercase `ms`.
  26. *
  27. * @param {string} string
  28. * @return {string}
  29. */
  30. function camelizeStyleName(string) {
  31. return camelize(string.replace(msPattern, 'ms-'));
  32. }
  33. module.exports = camelizeStyleName;