@@ -139,7 +139,7 @@ const getComponent = (instance, prop = 'default', options = instance, execute =
139
139
}
140
140
} else if ( isVNode ( instance ) ) {
141
141
const temp = instance . props && instance . props [ prop ] ;
142
- if ( temp !== undefined ) {
142
+ if ( temp !== undefined && temp !== null ) {
143
143
return typeof temp === 'function' && execute ? temp ( options ) : temp ;
144
144
} else if ( instance . children && instance . children [ prop ] ) {
145
145
let com = instance . children [ prop ] ;
@@ -305,18 +305,29 @@ export function isFragment(c) {
305
305
}
306
306
307
307
export function isEmptyElement ( c ) {
308
- return c . type === Comment || ( c . type === Text && c . children . trim ( ) === '' ) ;
308
+ return (
309
+ c . type === Comment ||
310
+ ( c . type === Fragment && c . children . length === 0 ) ||
311
+ ( c . type === Text && c . children . trim ( ) === '' )
312
+ ) ;
309
313
}
310
314
311
315
export function isStringElement ( c ) {
312
316
return ! c . tag ;
313
317
}
314
318
315
319
export function filterEmpty ( children = [ ] ) {
316
- if ( isFragment ( children ) ) {
317
- return children [ 0 ] . children . filter ( c => ! isEmptyElement ( c ) ) ;
318
- }
319
- return children . filter ( c => ! isEmptyElement ( c ) ) ;
320
+ const res = [ ] ;
321
+ children . forEach ( child => {
322
+ if ( Array . isArray ( child ) ) {
323
+ res . push ( ...child ) ;
324
+ } else if ( child . type === Fragment ) {
325
+ res . push ( ...child . children ) ;
326
+ } else {
327
+ res . push ( child ) ;
328
+ }
329
+ } ) ;
330
+ return res . filter ( c => ! isEmptyElement ( c ) ) ;
320
331
}
321
332
const initDefaultProps = ( propTypes , defaultProps ) => {
322
333
Object . keys ( defaultProps ) . forEach ( k => {
0 commit comments