Is there any condition for getting the appropriate names?
The function I am writing is to set the style via element.style[propnameCamelCase]
and get the existing display value via document.defaultView.getComputedStyle(element,'').getPropertyValue(propname-regular)
, and I can hardly justify passing two separate , but semantically identical arguments to this function.
I know that for most of them this is a fairly simple transcription between camelCase and hyphens with the same words, so I can use regular expressions to convert them. But maybe there are a few that are not like that?
On top of my head, itβs hard for me to figure out how to deal with capital letters for a camel case with regular expressions.
edit : Ah, I could use the regex replacement function, every time I see a hyphen, we convert the next letter to uppercase.
source share