@@ -2,6 +2,7 @@ import { string_literal } from '../../utils/stringify';
2
2
import Renderer , { RenderOptions } from '../Renderer' ;
3
3
import { get_slot_scope } from './shared/get_slot_scope' ;
4
4
import InlineComponent from '../../nodes/InlineComponent' ;
5
+ import remove_whitespace_children from './utils/remove_whitespace_children' ;
5
6
import { p , x } from 'code-red' ;
6
7
7
8
function get_prop_value ( attribute ) {
@@ -67,12 +68,14 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
67
68
68
69
const slot_fns = [ ] ;
69
70
70
- if ( node . children . length ) {
71
+ const children = remove_whitespace_children ( node . children , node . next ) ;
72
+
73
+ if ( children . length ) {
71
74
const slot_scopes = new Map ( ) ;
72
75
73
76
renderer . push ( ) ;
74
77
75
- renderer . render ( node . children , Object . assign ( { } , options , {
78
+ renderer . render ( children , Object . assign ( { } , options , {
76
79
slot_scopes
77
80
} ) ) ;
78
81
@@ -82,9 +85,11 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
82
85
} ) ;
83
86
84
87
slot_scopes . forEach ( ( { input, output } , name ) => {
85
- slot_fns . push (
86
- p `${ name } : (${ input } ) => ${ output } `
87
- ) ;
88
+ if ( ! is_empty_template_literal ( output ) ) {
89
+ slot_fns . push (
90
+ p `${ name } : (${ input } ) => ${ output } `
91
+ ) ;
92
+ }
88
93
} ) ;
89
94
}
90
95
@@ -94,3 +99,11 @@ export default function(node: InlineComponent, renderer: Renderer, options: Rend
94
99
95
100
renderer . add_expression ( x `@validate_component(${ expression } , "${ node . name } ").$$render($$result, ${ props } , ${ bindings } , ${ slots } )` ) ;
96
101
}
102
+
103
+ function is_empty_template_literal ( template_literal ) {
104
+ return (
105
+ template_literal . expressions . length === 0 &&
106
+ template_literal . quasis . length === 1 &&
107
+ template_literal . quasis [ 0 ] . value . raw === ""
108
+ ) ;
109
+ }
0 commit comments