@@ -9,6 +9,10 @@ import has from 'lodash/has';
99import flattenDeep from 'lodash/flattenDeep' ;
1010import isString from 'lodash/isString' ;
1111import trim from 'lodash/trim' ;
12+ import replace from 'lodash/replace' ;
13+ import toUpper from 'lodash/toUpper' ;
14+ import toLower from 'lodash/toLower' ;
15+ import split from 'lodash/split' ;
1216
1317/**
1418 * Useful utilities for working with JSX.
@@ -43,7 +47,7 @@ export function parseHTML(html: string): Object {
4347 * @return {string } JSX style key
4448 */
4549export function toJSXKey ( key : string ) : string {
46- return ( / ^ - m s - / . test ( key ) ? key . substr ( 1 ) : key ) . replace ( / - ( .) / g, ( match , chr ) => chr . toUpperCase ( ) ) ;
50+ return replace ( / ^ - m s - / . test ( key ) ? key . substr ( 1 ) : key , / - ( .) / g, ( match , chr ) => toUpper ( chr ) ) ;
4751}
4852
4953/**
@@ -56,12 +60,12 @@ export function toJSXKey(key: string): string {
5660 */
5761export function transformStyle ( object : Object ) {
5862 if ( has ( object , 'style' ) ) {
59- object . style = transform ( object . style . split ( ';' ) , ( result , style ) => {
63+ object . style = transform ( split ( object . style , ';' ) , ( result , style ) => {
6064 const firstColon = style . indexOf ( ':' ) ,
61- key = style . substr ( 0 , firstColon ) . trim ( ) ;
65+ key = trim ( style . substr ( 0 , firstColon ) ) ;
6266
6367 if ( key ) {
64- result [ toJSXKey ( key . toLowerCase ( ) ) ] = style . substr ( firstColon + 1 ) . trim ( ) ;
68+ result [ toJSXKey ( toLower ( key ) ) ] = trim ( style . substr ( firstColon + 1 ) ) ;
6569 }
6670 } , { } ) ;
6771 }
0 commit comments