File tree 3 files changed +13
-11
lines changed
3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import add_to_set from '../utils/add_to_set';
10
10
import get_object from '../utils/get_object' ;
11
11
import { extract_names } from '../utils/scope' ;
12
12
import { nodes_match } from '../../utils/nodes_match' ;
13
- import { sanitize } from '../../utils/names' ;
13
+ import { sanitize , quote_prop_if_necessary , quote_name_if_necessary } from '../../utils/names' ;
14
14
15
15
export default function dom (
16
16
component : Component ,
@@ -305,8 +305,7 @@ export default function dom(
305
305
const reactive_stores = component . vars . filter ( variable => variable . name [ 0 ] === '$' && variable . name [ 1 ] !== '$' ) ;
306
306
307
307
if ( renderer . slots . size > 0 ) {
308
- const arr = Array . from ( renderer . slots ) ;
309
- filtered_declarations . push ( ...arr . map ( name => `$$slot_${ sanitize ( name ) } ` ) , '$$scope' ) ;
308
+ filtered_declarations . push ( '$$slots' , '$$scope' ) ;
310
309
}
311
310
312
311
if ( renderer . binding_groups . length > 0 ) {
@@ -399,7 +398,7 @@ export default function dom(
399
398
400
399
${ component . javascript }
401
400
402
- ${ renderer . slots . size && `let { ${ [ ... renderer . slots ] . map ( name => `$$slot_ ${ sanitize ( name ) } ` ) . join ( ', ' ) } , $$scope } = $$props;` }
401
+ ${ renderer . slots . size && `let { $$ slots = { }, $$scope } = $$props;` }
403
402
404
403
${ renderer . binding_groups . length > 0 && `const $$binding_groups = [${ renderer . binding_groups . map ( _ => `[]` ) . join ( ', ' ) } ];` }
405
404
Original file line number Diff line number Diff line change @@ -119,16 +119,19 @@ export default class InlineComponentWrapper extends Wrapper {
119
119
120
120
const uses_spread = ! ! this . node . attributes . find ( a => a . is_spread ) ;
121
121
122
- const slot_props = Array . from ( this . slots ) . map ( ( [ name , slot ] ) => `$$slot_${ sanitize ( name ) } : [${ slot . block . name } ${ slot . fn ? `, ${ slot . fn } ` : '' } ]` ) ;
123
- if ( slot_props . length > 0 ) slot_props . push ( `$$scope: { ctx }` ) ;
122
+ const slot_props = Array . from ( this . slots ) . map ( ( [ name , slot ] ) => `${ quote_name_if_necessary ( name ) } : [${ slot . block . name } ${ slot . fn ? `, ${ slot . fn } ` : '' } ]` ) ;
123
+
124
+ const initial_props = slot_props . length > 0
125
+ ? [ `$$slots: ${ stringify_props ( slot_props ) } ` , `$$scope: { ctx }` ]
126
+ : [ ] ;
124
127
125
128
const attribute_object = uses_spread
126
- ? stringify_props ( slot_props )
129
+ ? stringify_props ( initial_props )
127
130
: stringify_props (
128
- this . node . attributes . map ( attr => `${ quote_name_if_necessary ( attr . name ) } : ${ attr . get_value ( block ) } ` ) . concat ( slot_props )
131
+ this . node . attributes . map ( attr => `${ quote_name_if_necessary ( attr . name ) } : ${ attr . get_value ( block ) } ` ) . concat ( initial_props )
129
132
) ;
130
133
131
- if ( this . node . attributes . length || this . node . bindings . length || slot_props . length ) {
134
+ if ( this . node . attributes . length || this . node . bindings . length || initial_props . length ) {
132
135
if ( ! uses_spread && this . node . bindings . length === 0 ) {
133
136
component_opts . push ( `props: ${ attribute_object } ` ) ;
134
137
} else {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import Block from '../Block';
4
4
import Slot from '../../nodes/Slot' ;
5
5
import FragmentWrapper from './Fragment' ;
6
6
import deindent from '../../utils/deindent' ;
7
- import { sanitize } from '../../../utils/names' ;
7
+ import { sanitize , quote_prop_if_necessary } from '../../../utils/names' ;
8
8
import add_to_set from '../../utils/add_to_set' ;
9
9
import get_slot_data from '../../utils/get_slot_data' ;
10
10
import { stringify_props } from '../../utils/stringify_props' ;
@@ -99,7 +99,7 @@ export default class SlotWrapper extends Wrapper {
99
99
const slot_definition = block . get_unique_name ( `${ sanitize ( slot_name ) } _slot` ) ;
100
100
101
101
block . builders . init . add_block ( deindent `
102
- const ${ slot_definition } = ctx.$$slot_ ${ sanitize ( slot_name ) } ;
102
+ const ${ slot_definition } = ctx.$$slots ${ quote_prop_if_necessary ( slot_name ) } ;
103
103
const ${ slot } = @create_slot(${ slot_definition } , ctx, ${ get_slot_context } );
104
104
` ) ;
105
105
You can’t perform that action at this time.
0 commit comments