@@ -4,7 +4,6 @@ import map_children from './shared/map_children.js';
4
4
import Binding from './Binding.js' ;
5
5
import EventHandler from './EventHandler.js' ;
6
6
import Expression from './shared/Expression.js' ;
7
- import Let from './Let.js' ;
8
7
import compiler_errors from '../compiler_errors.js' ;
9
8
import { regex_only_whitespaces } from '../../utils/patterns.js' ;
10
9
@@ -22,9 +21,6 @@ export default class InlineComponent extends Node {
22
21
/** @type {import('./EventHandler.js').default[] } */
23
22
handlers = [ ] ;
24
23
25
- /** @type {import('./Let.js').default[] } */
26
- lets = [ ] ;
27
-
28
24
/** @type {import('./Attribute.js').default[] } */
29
25
css_custom_properties = [ ] ;
30
26
@@ -37,6 +33,8 @@ export default class InlineComponent extends Node {
37
33
/** @type {string } */
38
34
namespace ;
39
35
36
+ /** @type {Attribute[] } */
37
+ let_attributes ;
40
38
/**
41
39
* @param {import('../Component.js').default } component
42
40
* @param {import('./shared/Node.js').default } parent
@@ -58,6 +56,8 @@ export default class InlineComponent extends Node {
58
56
this . name === 'svelte:component'
59
57
? new Expression ( component , this , scope , info . expression )
60
58
: null ;
59
+
60
+ const let_attributes = ( this . let_attributes = [ ] ) ;
61
61
info . attributes . forEach (
62
62
/** @param {import('../../interfaces.js').BaseDirective | import('../../interfaces.js').Attribute | import('../../interfaces.js').SpreadAttribute } node */ (
63
63
node
@@ -84,7 +84,7 @@ export default class InlineComponent extends Node {
84
84
this . handlers . push ( new EventHandler ( component , this , scope , node ) ) ;
85
85
break ;
86
86
case 'Let' :
87
- this . lets . push ( new Let ( component , this , scope , node ) ) ;
87
+ let_attributes . push ( node ) ;
88
88
break ;
89
89
case 'Transition' :
90
90
return component . error ( node , compiler_errors . invalid_transition ) ;
@@ -98,21 +98,9 @@ export default class InlineComponent extends Node {
98
98
/* eslint-enable no-fallthrough */
99
99
}
100
100
) ;
101
- if ( this . lets . length > 0 ) {
102
- this . scope = scope . child ( ) ;
103
- this . lets . forEach (
104
- /** @param {any } l */ ( l ) => {
105
- const dependencies = new Set ( [ l . name . name ] ) ;
106
- l . names . forEach (
107
- /** @param {any } name */ ( name ) => {
108
- this . scope . add ( name , dependencies , this ) ;
109
- }
110
- ) ;
111
- }
112
- ) ;
113
- } else {
114
- this . scope = scope ;
115
- }
101
+
102
+ this . scope = scope ;
103
+
116
104
this . handlers . forEach (
117
105
/** @param {any } handler */ ( handler ) => {
118
106
handler . modifiers . forEach (
@@ -178,6 +166,18 @@ export default class InlineComponent extends Node {
178
166
children : info . children
179
167
} ) ;
180
168
}
169
+
170
+ if ( let_attributes . length ) {
171
+ // copy let: attribute from <Component /> to <svelte:fragment slot="default" />
172
+ // as they are for `slot="default"` only
173
+ children . forEach ( ( child ) => {
174
+ const slot = child . attributes . find ( ( attribute ) => attribute . name === 'slot' ) ;
175
+ if ( ! slot || slot . value [ 0 ] . data === 'default' ) {
176
+ child . attributes . push ( ...let_attributes ) ;
177
+ }
178
+ } ) ;
179
+ }
180
+
181
181
this . children = map_children ( component , this , this . scope , children ) ;
182
182
}
183
183
get slot_template_name ( ) {
0 commit comments