@@ -3,6 +3,7 @@ import type {
33 SvelteAnimationDirective ,
44 SvelteAttribute ,
55 SvelteShorthandAttribute ,
6+ SvelteAttachTag ,
67 SvelteBindingDirective ,
78 SvelteClassDirective ,
89 SvelteDirective ,
@@ -48,6 +49,7 @@ export function* convertAttributes(
4849 | SvAST . AttributeOrDirective
4950 | Compiler . Attribute
5051 | Compiler . SpreadAttribute
52+ | Compiler . AttachTag
5153 | Compiler . Directive
5254 ) [ ] ,
5355 parent : SvelteStartTag ,
@@ -56,6 +58,7 @@ export function* convertAttributes(
5658 | SvelteAttribute
5759 | SvelteShorthandAttribute
5860 | SvelteSpreadAttribute
61+ | SvelteAttachTag
5962 | SvelteDirective
6063 | SvelteStyleDirective
6164> {
@@ -68,6 +71,10 @@ export function* convertAttributes(
6871 yield convertSpreadAttribute ( attr , parent , ctx ) ;
6972 continue ;
7073 }
74+ if ( attr . type === "AttachTag" ) {
75+ yield convertAttachTag ( attr , parent , ctx ) ;
76+ continue ;
77+ }
7178 if ( attr . type === "BindDirective" || attr . type === "Binding" ) {
7279 yield convertBindingDirective ( attr , parent , ctx ) ;
7380 continue ;
@@ -344,6 +351,31 @@ function convertSpreadAttribute(
344351 return attribute ;
345352}
346353
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+
347379/** Convert for Binding Directive */
348380function convertBindingDirective (
349381 node : SvAST . DirectiveForExpression | Compiler . BindDirective ,
0 commit comments