public void setStyleProperty ( Element e , String prop , String val ) { if ( e == null || prop == null ) { return ; } prop = fixPropertyName ( prop ) ; // put it in lower-case only when all letters are upper-case, to avoid // modifying already camelized properties if ( prop . matches ( "^[A-Z]+$" ) ) { prop = prop . toLowerCase ( ) ; } prop = JsUtils . camelize ( prop ) ; if ( val == null || val . trim ( ) . length ( ) == 0 ) { removeStyleProperty ( e , prop ) ; } else { if ( val . matches ( "-?[\\d\\.]+" ) && ! cssNumberRegex . test ( prop ) ) { val += "px" ; } e . getStyle ( ) . setProperty ( prop , val ) ; } }
Set the value of a style property of an element .