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;
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
|
2015-11-05 04:14:21 +03:00
|
|
|
function addPrefixesTo (style, property, value) {
|
|
|
|
const vendor = getPrefixes(property, value);
|
|
|
|
for (const prefix in vendor) {
|
|
|
|
style[prefix] = vendor[prefix];
|
|
|
|
}
|
2015-09-05 21:16:15 +03:00
|
|
|
|
2015-11-05 04:14:21 +03:00
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
|
|
|
function prefixer (style) {
|
|
|
|
const _style = {};
|
|
|
|
for (const property in style) {
|
|
|
|
_style[property] = style[property];
|
|
|
|
if (properties[property]) {
|
|
|
|
addPrefixesTo(_style, property, style[property]);
|
2015-09-05 21:16:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return _style;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = prefixer;
|