UNPKG

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