We\'d like to convert a CSS style entered as string into a JS object.
E.g.,
var input = \" border:solid 1px; color:red \";
expec
In a functional form:
var styleInput = " border:solid 1px; color:red ";
var result = styleInput.split(';').reduce(function (ruleMap, ruleString) {
var rulePair = ruleString.split(':');
ruleMap[rulePair[0].trim()] = rulePair[1].trim();
return ruleMap;
}, {});
Trim the strings before using them as object keys.