@@ -26,7 +26,8 @@ export type Node =
2626 | Block
2727 | BlockParameter
2828 | Component
29- | Directive ;
29+ | Directive
30+ | StartTagComment ;
3031
3132export abstract class NodeWithI18n implements BaseNode {
3233 constructor (
@@ -97,6 +98,17 @@ export class Attribute extends NodeWithI18n {
9798 }
9899}
99100
101+ export class StartTagComment implements BaseNode {
102+ constructor (
103+ public value : string ,
104+ public type : 'single' | 'multi' ,
105+ public sourceSpan : ParseSourceSpan ,
106+ ) { }
107+ visit ( visitor : Visitor , context : any ) : any {
108+ return visitor . visitAttributeComment ? visitor . visitAttributeComment ( this , context ) : undefined ;
109+ }
110+ }
111+
100112export class Element extends NodeWithI18n {
101113 constructor (
102114 public name : string ,
@@ -109,6 +121,7 @@ export class Element extends NodeWithI18n {
109121 public endSourceSpan : ParseSourceSpan | null = null ,
110122 readonly isVoid : boolean ,
111123 i18n ?: I18nMeta ,
124+ public comments : StartTagComment [ ] = [ ] ,
112125 ) {
113126 super ( sourceSpan , i18n ) ;
114127 }
@@ -159,6 +172,7 @@ export class Component extends NodeWithI18n {
159172 readonly startSourceSpan : ParseSourceSpan ,
160173 public endSourceSpan : ParseSourceSpan | null = null ,
161174 i18n ?: I18nMeta ,
175+ public comments : StartTagComment [ ] = [ ] ,
162176 ) {
163177 super ( sourceSpan , i18n ) ;
164178 }
@@ -223,6 +237,7 @@ export interface Visitor {
223237 visitLetDeclaration ( decl : LetDeclaration , context : any ) : any ;
224238 visitComponent ( component : Component , context : any ) : any ;
225239 visitDirective ( directive : Directive , context : any ) : any ;
240+ visitAttributeComment ?( comment : StartTagComment , context : any ) : any ;
226241}
227242
228243export function visitAll ( visitor : Visitor , nodes : Node [ ] , context : any = null ) : any [ ] {
@@ -247,11 +262,13 @@ export class RecursiveVisitor implements Visitor {
247262 this . visitChildren ( context , ( visit ) => {
248263 visit ( ast . attrs ) ;
249264 visit ( ast . directives ) ;
265+ visit ( ast . comments ) ;
250266 visit ( ast . children ) ;
251267 } ) ;
252268 }
253269
254270 visitAttribute ( ast : Attribute , context : any ) : any { }
271+ visitAttributeComment ( ast : StartTagComment , context : any ) : any { }
255272 visitText ( ast : Text , context : any ) : any { }
256273 visitComment ( ast : Comment , context : any ) : any { }
257274
@@ -277,6 +294,7 @@ export class RecursiveVisitor implements Visitor {
277294 visitComponent ( component : Component , context : any ) {
278295 this . visitChildren ( context , ( visit ) => {
279296 visit ( component . attrs ) ;
297+ visit ( component . comments ) ;
280298 visit ( component . children ) ;
281299 } ) ;
282300 }
0 commit comments