@@ -3,6 +3,7 @@ import type {
3
3
SvelteAnimationDirective ,
4
4
SvelteAttribute ,
5
5
SvelteShorthandAttribute ,
6
+ SvelteAttachTag ,
6
7
SvelteBindingDirective ,
7
8
SvelteClassDirective ,
8
9
SvelteDirective ,
@@ -48,6 +49,7 @@ export function* convertAttributes(
48
49
| SvAST . AttributeOrDirective
49
50
| Compiler . Attribute
50
51
| Compiler . SpreadAttribute
52
+ | Compiler . AttachTag
51
53
| Compiler . Directive
52
54
) [ ] ,
53
55
parent : SvelteStartTag ,
@@ -56,6 +58,7 @@ export function* convertAttributes(
56
58
| SvelteAttribute
57
59
| SvelteShorthandAttribute
58
60
| SvelteSpreadAttribute
61
+ | SvelteAttachTag
59
62
| SvelteDirective
60
63
| SvelteStyleDirective
61
64
> {
@@ -68,6 +71,10 @@ export function* convertAttributes(
68
71
yield convertSpreadAttribute ( attr , parent , ctx ) ;
69
72
continue ;
70
73
}
74
+ if ( attr . type === "AttachTag" ) {
75
+ yield convertAttachTag ( attr , parent , ctx ) ;
76
+ continue ;
77
+ }
71
78
if ( attr . type === "BindDirective" || attr . type === "Binding" ) {
72
79
yield convertBindingDirective ( attr , parent , ctx ) ;
73
80
continue ;
@@ -344,6 +351,31 @@ function convertSpreadAttribute(
344
351
return attribute ;
345
352
}
346
353
354
+ function convertAttachTag (
355
+ node : Compiler . AttachTag ,
356
+ parent : SvelteAttachTag [ "parent" ] ,
357
+ ctx : Context ,
358
+ ) : SvelteAttachTag {
359
+ const attachTag : SvelteAttachTag = {
360
+ type : "SvelteAttachTag" ,
361
+ expression : node . expression ,
362
+ parent,
363
+ ...ctx . getConvertLocation ( node ) ,
364
+ } ;
365
+
366
+ ctx . scriptLet . addExpression ( node . expression , attachTag , null , ( es ) => {
367
+ attachTag . expression = es ;
368
+ } ) ;
369
+
370
+ const atAttachStart = ctx . code . indexOf ( "@attach" , attachTag . range [ 0 ] ) ;
371
+ ctx . addToken ( "MustacheKeyword" , {
372
+ start : atAttachStart ,
373
+ end : atAttachStart + 7 ,
374
+ } ) ;
375
+
376
+ return attachTag ;
377
+ }
378
+
347
379
/** Convert for Binding Directive */
348
380
function convertBindingDirective (
349
381
node : SvAST . DirectiveForExpression | Compiler . BindDirective ,
0 commit comments