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