Skip to content

Commit 3204604

Browse files
authored
Support for svelte v3.46.1 and change AST (#130)
* Support for svelte v3.46.1 * fix
1 parent 4d86de9 commit 3204604

14 files changed

+2973
-388
lines changed

src/ast.ts

+25-7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export type SvelteNode =
7373
| SvelteShorthandAttribute
7474
| SvelteSpreadAttribute
7575
| SvelteDirective
76+
| SvelteStyleDirective
7677
| SvelteSpecialDirective
7778
| SvelteDirectiveKey
7879
| SvelteSpecialDirectiveKey
@@ -179,6 +180,7 @@ export interface SvelteStartTag extends BaseNode {
179180
| SvelteShorthandAttribute
180181
| SvelteSpreadAttribute
181182
| SvelteDirective
183+
| SvelteStyleDirective
182184
| SvelteSpecialDirective
183185
)[]
184186
selfClosing: boolean
@@ -263,6 +265,7 @@ interface BaseSvelteMustacheTag extends BaseNode {
263265
| SvelteAwaitCatchBlock
264266
| SvelteKeyBlock
265267
| SvelteAttribute
268+
| SvelteStyleDirective
266269
}
267270
/** Node of mustache tag. e.g. `{...}``. Like JSXExpressionContainer */
268271
export interface SvelteMustacheTagText extends BaseSvelteMustacheTag {
@@ -506,7 +509,7 @@ export interface SvelteAttribute extends BaseNode {
506509
type: "SvelteAttribute"
507510
key: SvelteName
508511
boolean: boolean
509-
value: (SvelteLiteral | (SvelteMustacheTag & { kind: "text" }))[]
512+
value: (SvelteLiteral | SvelteMustacheTagText)[]
510513
parent: SvelteStartTag
511514
}
512515
/** Node of shorthand attribute. e.g. `<img {src}>` */
@@ -529,7 +532,6 @@ export type SvelteDirective =
529532
| SvelteAnimationDirective
530533
| SvelteBindingDirective
531534
| SvelteClassDirective
532-
| SvelteStyleDirective
533535
| SvelteEventHandlerDirective
534536
| SvelteLetDirective
535537
| SvelteRefDirective
@@ -538,7 +540,7 @@ export interface SvelteDirectiveKey extends BaseNode {
538540
type: "SvelteDirectiveKey"
539541
name: ESTree.Identifier | SvelteName
540542
modifiers: string[]
541-
parent: SvelteDirective
543+
parent: SvelteDirective | SvelteStyleDirective
542544
}
543545

544546
interface BaseSvelteDirective extends BaseNode {
@@ -563,10 +565,6 @@ export interface SvelteClassDirective extends BaseSvelteDirective {
563565
kind: "Class"
564566
expression: null | ESTree.Expression
565567
}
566-
export interface SvelteStyleDirective extends BaseSvelteDirective {
567-
kind: "Style"
568-
expression: null | ESTree.Expression | SvelteLiteral
569-
}
570568
export interface SvelteEventHandlerDirective extends BaseSvelteDirective {
571569
kind: "EventHandler"
572570
expression: null | ESTree.Expression
@@ -585,6 +583,26 @@ export interface SvelteTransitionDirective extends BaseSvelteDirective {
585583
outro: boolean
586584
expression: null | ESTree.Expression
587585
}
586+
587+
/** Node of style directive. e.g. `<input style:color />` */
588+
export type SvelteStyleDirective =
589+
| SvelteStyleDirectiveShorthand
590+
| SvelteStyleDirectiveLongform
591+
interface BaseSvelteStyleDirective extends BaseNode {
592+
type: "SvelteStyleDirective"
593+
key: SvelteDirectiveKey
594+
value: (SvelteLiteral | SvelteMustacheTagText)[]
595+
parent: SvelteStartTag
596+
}
597+
export interface SvelteStyleDirectiveShorthand
598+
extends BaseSvelteStyleDirective {
599+
shorthand: true
600+
value: []
601+
}
602+
export interface SvelteStyleDirectiveLongform extends BaseSvelteStyleDirective {
603+
shorthand: false
604+
value: (SvelteLiteral | SvelteMustacheTagText)[]
605+
}
588606
export interface SvelteSpecialDirectiveKey extends BaseNode {
589607
type: "SvelteSpecialDirectiveKey"
590608
parent: SvelteSpecialDirective

0 commit comments

Comments
 (0)