@@ -57,6 +57,10 @@ export default function renderToString(vnode, context, opts, inner) {
57
57
let pretty = opts . pretty ,
58
58
indentChar = typeof pretty === 'string' ? pretty : '\t' ;
59
59
60
+ if ( vnode == null ) {
61
+ return '<!---->' ;
62
+ }
63
+
60
64
// #text nodes
61
65
if ( ! nodeName ) {
62
66
return encodeEntities ( vnode ) ;
@@ -153,31 +157,31 @@ export default function renderToString(vnode, context, opts, inner) {
153
157
s += html ;
154
158
}
155
159
else {
156
- let len = children && children . length ;
157
- if ( len ) {
158
- let pieces = [ ] ,
159
- hasLarge = ~ s . indexOf ( '\n' ) ;
160
- for ( let i = 0 ; i < len ; i ++ ) {
161
- let child = children [ i ] ;
162
- if ( ! falsey ( child ) ) {
163
- let ret = renderToString ( child , context , opts , true ) ;
164
- if ( ! hasLarge && pretty && isLargeString ( ret ) ) hasLarge = true ;
165
- pieces . push ( ret ) ;
166
- }
160
+ let len = children && children . length ,
161
+ pieces = [ ] ,
162
+ hasLarge = ~ s . indexOf ( '\n' ) ;
163
+ for ( let i = 0 ; i < len ; i ++ ) {
164
+ let child = children [ i ] ;
165
+ if ( ! falsey ( child ) ) {
166
+ let ret = renderToString ( child , context , opts , true ) ;
167
+ if ( ! hasLarge && pretty && isLargeString ( ret ) ) hasLarge = true ;
168
+ pieces . push ( ret ) ;
167
169
}
168
- if ( hasLarge ) {
169
- for ( let i = pieces . length ; i -- ; ) {
170
- pieces [ i ] = '\n' + indentChar + indent ( pieces [ i ] , indentChar ) ;
171
- }
170
+ }
171
+ if ( hasLarge ) {
172
+ for ( let i = pieces . length ; i -- ; ) {
173
+ pieces [ i ] = '\n' + indentChar + indent ( pieces [ i ] , indentChar ) ;
172
174
}
175
+ }
176
+ if ( pieces . length ) {
173
177
s += pieces . join ( '' ) ;
174
178
}
175
179
else if ( opts && opts . xml ) {
176
180
return s . substring ( 0 , s . length - 1 ) + ' />' ;
177
181
}
178
182
}
179
183
180
- if ( VOID_ELEMENTS . indexOf ( nodeName ) === - 1 ) {
184
+ if ( opts . jsx || VOID_ELEMENTS . indexOf ( nodeName ) === - 1 ) {
181
185
if ( pretty && ~ s . indexOf ( '\n' ) ) s += '\n' ;
182
186
s += `</${ nodeName } >` ;
183
187
}
0 commit comments