You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
536 B

2 years ago
  1. "use strict";
  2. const pattern = /-(\w|$)/g;
  3. const callback = (dashChar, char) => char.toUpperCase();
  4. const camelCaseCSS = property =>
  5. {
  6. property = property.toLowerCase();
  7. // NOTE :: IE8's "styleFloat" is intentionally not supported
  8. if (property === "float")
  9. {
  10. return "cssFloat";
  11. }
  12. // Microsoft vendor-prefixes are uniquely cased
  13. else if (property.startsWith("-ms-"))
  14. {
  15. return property.substr(1).replace(pattern, callback);
  16. }
  17. else
  18. {
  19. return property.replace(pattern, callback);
  20. }
  21. };
  22. module.exports = camelCaseCSS;