File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export function styleObjToCss(s) {
2121 if ( val != null ) {
2222 if ( str ) str += ' ' ;
2323 // str += jsToCss(prop);
24- str += JS_TO_CSS [ prop ] || ( JS_TO_CSS [ prop ] = prop . replace ( / ( [ A - Z ] ) / g, '-$1' ) . toLowerCase ( ) ) ;
24+ str += prop [ 0 ] == '-' ? prop : ( JS_TO_CSS [ prop ] || ( JS_TO_CSS [ prop ] = prop . replace ( / ( [ A - Z ] ) / g, '-$1' ) . toLowerCase ( ) ) ) ;
2525 str += ': ' ;
2626 str += val ;
2727 if ( typeof val === 'number' && IS_NON_DIMENSIONAL . test ( prop ) === false ) {
Original file line number Diff line number Diff line change @@ -145,6 +145,13 @@ describe('render', () => {
145145 expect ( rendered ) . to . equal ( expected ) ;
146146 } ) ;
147147
148+ it ( 'should preserve CSS Custom Properties' , ( ) => {
149+ let rendered = render ( < div style = { { '--foo' : 1 , '--foo-bar' : '2' } } /> ) ,
150+ expected = `<div style="--foo: 1; --foo-bar: 2;"></div>` ;
151+
152+ expect ( rendered ) . to . equal ( expected ) ;
153+ } ) ;
154+
148155 it ( 'should ignore empty object styles' , ( ) => {
149156 let rendered = render ( < div style = { { } } /> ) ,
150157 expected = `<div></div>` ;
You can’t perform that action at this time.
0 commit comments