react-toolbox/components/utils/prefixer.js

32 lines
636 B
JavaScript
Raw Normal View History

2015-09-05 21:16:15 +03:00
const WEBKIT = 'Webkit';
const MICROSOFT = 'Ms';
const properties = {
transform: [WEBKIT, MICROSOFT]
};
function capitalize (string) {
return string.charAt(0).toUpperCase() + string.substr(1);
}
function getPrefixes (property, value) {
return properties[property].reduce(function (acc, item) {
acc[`${item}${capitalize(property)}`] = value;
return acc;
}, {});
}
function prefixer (style) {
let _style = style;
for (const property in properties) {
2015-09-05 21:16:15 +03:00
if (style[property]) {
_style = Object.assign(_style, getPrefixes(property, style[property]));
}
}
return _style;
}
module.exports = prefixer;