@@ -52,8 +52,11 @@ export type SvelteNode =
52
52
| SvelteScriptElement
53
53
| SvelteStyleElement
54
54
| SvelteElement
55
+ | SvelteStartTag
56
+ | SvelteEndTag
55
57
| SvelteName
56
58
| SvelteText
59
+ | SvelteLiteral
57
60
| SvelteMustacheTag
58
61
| SvelteDebugTag
59
62
| SvelteIfBlock
@@ -92,40 +95,28 @@ type BaseSvelteElement = BaseNode
92
95
export interface SvelteScriptElement extends BaseSvelteElement {
93
96
type : "SvelteScriptElement"
94
97
name : SvelteName
95
- attributes : (
96
- | SvelteAttribute
97
- | SvelteShorthandAttribute
98
- | SvelteSpreadAttribute
99
- | SvelteDirective
100
- ) [ ]
98
+ startTag : SvelteStartTag
101
99
body : ESTree . Program [ "body" ]
100
+ endTag : SvelteEndTag | null
102
101
parent : SvelteProgram
103
102
}
104
103
/** Node of `<style>` element. */
105
104
export interface SvelteStyleElement extends BaseSvelteElement {
106
105
type : "SvelteStyleElement"
107
106
name : SvelteName
108
- attributes : (
109
- | SvelteAttribute
110
- | SvelteShorthandAttribute
111
- | SvelteSpreadAttribute
112
- | SvelteDirective
113
- ) [ ]
107
+ startTag : SvelteStartTag
114
108
children : [ SvelteText ]
109
+ endTag : SvelteEndTag | null
115
110
parent : SvelteProgram
116
111
}
117
112
/** Node of HTML element. */
118
113
export interface SvelteHTMLElement extends BaseSvelteElement {
119
114
type : "SvelteElement"
120
115
kind : "html"
121
116
name : SvelteName
122
- attributes : (
123
- | SvelteAttribute
124
- | SvelteShorthandAttribute
125
- | SvelteSpreadAttribute
126
- | SvelteDirective
127
- ) [ ]
117
+ startTag : SvelteStartTag
128
118
children : Child [ ]
119
+ endTag : SvelteEndTag | null
129
120
parent :
130
121
| SvelteProgram
131
122
| SvelteElement
@@ -142,13 +133,9 @@ export interface SvelteComponentElement extends BaseSvelteElement {
142
133
type : "SvelteElement"
143
134
kind : "component"
144
135
name : ESTree . Identifier | SvelteMemberExpressionName
145
- attributes : (
146
- | SvelteAttribute
147
- | SvelteShorthandAttribute
148
- | SvelteSpreadAttribute
149
- | SvelteDirective
150
- ) [ ]
136
+ startTag : SvelteStartTag
151
137
children : Child [ ]
138
+ endTag : SvelteEndTag | null
152
139
parent :
153
140
| SvelteProgram
154
141
| SvelteElement
@@ -165,14 +152,9 @@ export interface SvelteSpecialElement extends BaseSvelteElement {
165
152
type : "SvelteElement"
166
153
kind : "special"
167
154
name : SvelteName
168
- attributes : (
169
- | SvelteAttribute
170
- | SvelteShorthandAttribute
171
- | SvelteSpreadAttribute
172
- | SvelteDirective
173
- | SvelteSpecialDirective
174
- ) [ ]
155
+ startTag : SvelteStartTag
175
156
children : Child [ ]
157
+ endTag : SvelteEndTag | null
176
158
parent :
177
159
| SvelteProgram
178
160
| SvelteElement
@@ -184,6 +166,24 @@ export interface SvelteSpecialElement extends BaseSvelteElement {
184
166
| SvelteAwaitCatchBlock
185
167
| SvelteKeyBlock
186
168
}
169
+ /** Node of start tag. */
170
+ export interface SvelteStartTag extends BaseNode {
171
+ type : "SvelteStartTag"
172
+ attributes : (
173
+ | SvelteAttribute
174
+ | SvelteShorthandAttribute
175
+ | SvelteSpreadAttribute
176
+ | SvelteDirective
177
+ | SvelteSpecialDirective
178
+ ) [ ]
179
+ selfClosing : boolean
180
+ parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
181
+ }
182
+ /** Node of end tag. */
183
+ export interface SvelteEndTag extends BaseNode {
184
+ type : "SvelteEndTag"
185
+ parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
186
+ }
187
187
188
188
/** Node of names. It is used for element names other than components and normal attribute names. */
189
189
export interface SvelteName extends BaseNode {
@@ -216,21 +216,27 @@ type Child =
216
216
| SvelteKeyBlock
217
217
| SvelteHTMLComment
218
218
219
- /** Node of text line HTML text. */
219
+ /** Node of text. like HTML text. */
220
220
export interface SvelteText extends BaseNode {
221
221
type : "SvelteText"
222
222
value : string
223
223
parent :
224
224
| SvelteProgram
225
225
| SvelteElement
226
+ | SvelteStyleElement
226
227
| SvelteIfBlock
227
228
| SvelteElseBlock
228
229
| SvelteEachBlock
229
230
| SvelteAwaitPendingBlock
230
231
| SvelteAwaitThenBlock
231
232
| SvelteAwaitCatchBlock
232
233
| SvelteKeyBlock
233
- | SvelteAttribute
234
+ }
235
+ /** Node of literal. */
236
+ export interface SvelteLiteral extends BaseNode {
237
+ type : "SvelteLiteral"
238
+ value : string
239
+ parent : SvelteAttribute
234
240
}
235
241
236
242
interface BaseSvelteMustacheTag extends BaseNode {
@@ -375,21 +381,21 @@ export interface SvelteAttribute extends BaseNode {
375
381
type : "SvelteAttribute"
376
382
key : SvelteName
377
383
boolean : boolean
378
- value : ( SvelteText | ( SvelteMustacheTag & { kind : "text" } ) ) [ ]
379
- parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
384
+ value : ( SvelteLiteral | ( SvelteMustacheTag & { kind : "text" } ) ) [ ]
385
+ parent : SvelteStartTag
380
386
}
381
387
/** Node of shorthand attribute. e.g. `<img {src}>` */
382
388
export interface SvelteShorthandAttribute extends BaseNode {
383
389
type : "SvelteShorthandAttribute"
384
390
key : ESTree . Identifier
385
391
value : ESTree . Identifier
386
- parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
392
+ parent : SvelteStartTag
387
393
}
388
394
/** Node of spread attribute. e.g. `<Info {...pkg}/>`. Like JSXSpreadAttribute */
389
395
export interface SvelteSpreadAttribute extends BaseNode {
390
396
type : "SvelteSpreadAttribute"
391
397
argument : ESTree . Expression
392
- parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
398
+ parent : SvelteStartTag
393
399
}
394
400
395
401
/** Node of directive. e.g. `<input bind:value />` */
@@ -406,7 +412,7 @@ interface BaseSvelteDirective extends BaseNode {
406
412
type : "SvelteDirective"
407
413
name : ESTree . Identifier
408
414
modifiers : string [ ]
409
- parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
415
+ parent : SvelteStartTag
410
416
}
411
417
412
418
export interface SvelteActionDirective extends BaseSvelteDirective {
@@ -447,7 +453,7 @@ export interface SvelteSpecialDirective extends BaseNode {
447
453
type : "SvelteSpecialDirective"
448
454
kind : "this"
449
455
expression : ESTree . Expression
450
- parent : SvelteSpecialElement
456
+ parent : SvelteStartTag /* & { parent: SvelteSpecialElement } */
451
457
}
452
458
453
459
/** Node of `$` statement. */
0 commit comments