File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -38,11 +38,13 @@ export default function (babel) {
3838 ) ;
3939 }
4040
41- // converts
42- // <svg stroke-width="5">
43- // to
44- // <svg strokeWidth="5">
45- path . node . name . name = hyphenToCamel ( path . node . name . name ) ;
41+ if ( path . node . name . name . indexOf ( 'data-' ) !== 0 ) {
42+ // converts
43+ // <svg stroke-width="5">
44+ // to
45+ // <svg strokeWidth="5">
46+ path . node . name . name = hyphenToCamel ( path . node . name . name ) ;
47+ }
4648 }
4749 }
4850 } ;
Original file line number Diff line number Diff line change @@ -106,6 +106,17 @@ test('compression: namespace attr', function(t) {
106106 . catch ( t . end ) ;
107107} ) ;
108108
109+ test ( 'should not convert data-* props' , function ( t ) {
110+ t . plan ( 1 ) ;
111+
112+ loader ( `<svg data-foo="foo"></svg>` )
113+ . then ( component => render ( React . createElement ( component ) ) )
114+ . then ( r => {
115+ t . equal ( Object . keys ( r . props ) . indexOf ( 'data-foo' ) , 0 , 'data-* shouldn\'t be camelCased' )
116+ } )
117+ . catch ( t . end ) ;
118+ } ) ;
119+
109120const circle = `
110121<svg class='class1 class2' style='text-align: center; width: 100px;height:100px' fill="#ddd" pointer-events="stroke">
111122 <circle class='class3 class4' cx="50" cy="50" r="25" style="text-align: center; stroke: #000000;" stroke-width="5" />
You can’t perform that action at this time.
0 commit comments