UNPKG

965 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6var _camelCaseRegex = /([a-z])?([A-Z])/g;
7
8var _camelCaseReplacer = function _camelCaseReplacer(match, p1, p2) {
9 return (p1 || '') + '-' + p2.toLowerCase();
10};
11
12var _camelCaseToDashCase = function _camelCaseToDashCase(s) {
13 return s.replace(_camelCaseRegex, _camelCaseReplacer);
14};
15
16var camelCasePropsToDashCase = function camelCasePropsToDashCase(prefixedStyle) {
17 // Since prefix is expected to work on inline style objects, we must
18 // translate the keys to dash case for rendering to CSS.
19 return Object.keys(prefixedStyle).reduce(function (result, key) {
20 var dashCaseKey = _camelCaseToDashCase(key);
21
22 // Fix IE vendor prefix
23 if (/^ms-/.test(dashCaseKey)) {
24 dashCaseKey = '-' + dashCaseKey;
25 }
26
27 result[dashCaseKey] = prefixedStyle[key];
28 return result;
29 }, {});
30};
31
32exports.default = camelCasePropsToDashCase;
33module.exports = exports['default'];
\No newline at end of file