@@ -4,7 +4,6 @@ import map_children from './shared/map_children.js';
44import Binding from './Binding.js' ;
55import EventHandler from './EventHandler.js' ;
66import Expression from './shared/Expression.js' ;
7- import Let from './Let.js' ;
87import compiler_errors from '../compiler_errors.js' ;
98import { regex_only_whitespaces } from '../../utils/patterns.js' ;
109
@@ -22,9 +21,6 @@ export default class InlineComponent extends Node {
2221 /** @type {import('./EventHandler.js').default[] } */
2322 handlers = [ ] ;
2423
25- /** @type {import('./Let.js').default[] } */
26- lets = [ ] ;
27-
2824 /** @type {import('./Attribute.js').default[] } */
2925 css_custom_properties = [ ] ;
3026
@@ -37,6 +33,8 @@ export default class InlineComponent extends Node {
3733 /** @type {string } */
3834 namespace ;
3935
36+ /** @type {Attribute[] } */
37+ let_attributes ;
4038 /**
4139 * @param {import('../Component.js').default } component
4240 * @param {import('./shared/Node.js').default } parent
@@ -58,6 +56,8 @@ export default class InlineComponent extends Node {
5856 this . name === 'svelte:component'
5957 ? new Expression ( component , this , scope , info . expression )
6058 : null ;
59+
60+ const let_attributes = ( this . let_attributes = [ ] ) ;
6161 info . attributes . forEach (
6262 /** @param {import('../../interfaces.js').BaseDirective | import('../../interfaces.js').Attribute | import('../../interfaces.js').SpreadAttribute } node */ (
6363 node
@@ -84,7 +84,7 @@ export default class InlineComponent extends Node {
8484 this . handlers . push ( new EventHandler ( component , this , scope , node ) ) ;
8585 break ;
8686 case 'Let' :
87- this . lets . push ( new Let ( component , this , scope , node ) ) ;
87+ let_attributes . push ( node ) ;
8888 break ;
8989 case 'Transition' :
9090 return component . error ( node , compiler_errors . invalid_transition ) ;
@@ -98,21 +98,9 @@ export default class InlineComponent extends Node {
9898 /* eslint-enable no-fallthrough */
9999 }
100100 ) ;
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+
116104 this . handlers . forEach (
117105 /** @param {any } handler */ ( handler ) => {
118106 handler . modifiers . forEach (
@@ -178,6 +166,18 @@ export default class InlineComponent extends Node {
178166 children : info . children
179167 } ) ;
180168 }
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+
181181 this . children = map_children ( component , this , this . scope , children ) ;
182182 }
183183 get slot_template_name ( ) {
0 commit comments