@@ -85,8 +85,8 @@ function formatProps(props) {
85
85
return {
86
86
name : propName ,
87
87
value : formatPropValue ( props [ propName ] )
88
- . replace ( / ' ? < _ _ r e a c t E l e m e n t T o J S X S t r i n g _ _ R e a c t E l e m e n t _ _ > / g, '' )
89
- . replace ( / < \/ _ _ r e a c t E l e m e n t T o J S X S t r i n g _ _ R e a c t E l e m e n t _ _ > ' ? / g, '' )
88
+ . replace ( / ' ? < _ _ r e a c t E l e m e n t T o J S X S t r i n g _ _ W r a p p e r _ _ > / g, '' )
89
+ . replace ( / < \/ _ _ r e a c t E l e m e n t T o J S X S t r i n g _ _ W r a p p e r _ _ > ' ? / g, '' )
90
90
} ;
91
91
} ) ;
92
92
}
@@ -110,11 +110,13 @@ function formatValue(value) {
110
110
// // <div a={{b: <div />}} />
111
111
// we then remove the whole wrapping
112
112
// otherwise, the element would be surrounded by quotes: <div a={{b: '<div />'}} />
113
- return '<__reactElementToJSXString__ReactElement__ >' +
113
+ return '<__reactElementToJSXString__Wrapper__ >' +
114
114
toJSXString ( { ReactElement : value , inline : true } ) +
115
- '</__reactElementToJSXString__ReactElement__ >' ;
115
+ '</__reactElementToJSXString__Wrapper__ >' ;
116
116
} else if ( isPlainObject ( value ) ) {
117
- return stringifyObject ( value ) ;
117
+ return '<__reactElementToJSXString__Wrapper__>' +
118
+ stringifyObject ( value ) +
119
+ '</__reactElementToJSXString__Wrapper__>' ;
118
120
}
119
121
120
122
return value ;
@@ -127,13 +129,15 @@ function recurse({lvl, inline}) {
127
129
}
128
130
129
131
function stringifyObject ( obj ) {
130
- obj = traverse ( obj ) . map ( function ( value ) {
131
- if ( isElement ( value ) || this . isLeaf ) {
132
- this . update ( formatValue ( value ) ) ;
133
- }
134
- } ) ;
132
+ if ( Object . keys ( obj ) . length > 0 ) {
133
+ obj = traverse ( obj ) . map ( function ( value ) {
134
+ if ( isElement ( value ) || this . isLeaf ) {
135
+ this . update ( formatValue ( value ) ) ;
136
+ }
137
+ } ) ;
135
138
136
- obj = sortobject ( obj ) ;
139
+ obj = sortobject ( obj ) ;
140
+ }
137
141
138
142
return collapse ( stringify ( obj ) )
139
143
. replace ( / { / g, '{' )
0 commit comments