The thing is that some css properties have different name is javascript, for example textOverflow in js is text-overflow in css.
Is there a translation table somewhere in js engine that I can access or I must do myself a translation array or object like:
transObj = { textOverflow : 'text-overflow' };
For example I'm looping through this object and all I get is only js names:
for (var n in csd) {
if (!csd.hasOwnProperty(n)) continue;
csd[n].getTrueCSSName() // is there something like this ?
}
Or maybe simple regex replace will be ok, but I don't know if rule that all big letters in js names tranlsate to -[a-z] in css names ?
All css style which contain a - are replaced by their camelCase representation in ECMAscript, since we can't use - in all occasions. You can translate the names, by invoking a regular expression like this:
var name = "font-width";
// convert names like "font-width" into css camelCase form like "fontWidth"
name = name.replace( /-(\w)/g, function _replace( $1, $2 ) {
return $2.toUpperCase();
});
which also works for like -webkit-box-shadow or whatnot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With