react-native-web-headroom
Version:
React Native Web Headroom
33 lines (26 loc) • 965 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _camelCaseRegex = /([a-z])?([A-Z])/g;
var _camelCaseReplacer = function _camelCaseReplacer(match, p1, p2) {
return (p1 || '') + '-' + p2.toLowerCase();
};
var _camelCaseToDashCase = function _camelCaseToDashCase(s) {
return s.replace(_camelCaseRegex, _camelCaseReplacer);
};
var camelCasePropsToDashCase = function camelCasePropsToDashCase(prefixedStyle) {
// Since prefix is expected to work on inline style objects, we must
// translate the keys to dash case for rendering to CSS.
return Object.keys(prefixedStyle).reduce(function (result, key) {
var dashCaseKey = _camelCaseToDashCase(key);
// Fix IE vendor prefix
if (/^ms-/.test(dashCaseKey)) {
dashCaseKey = '-' + dashCaseKey;
}
result[dashCaseKey] = prefixedStyle[key];
return result;
}, {});
};
exports.default = camelCasePropsToDashCase;
module.exports = exports['default'];