Skip to content

Support for svelte v3.46.1 and change AST #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export type SvelteNode =
| SvelteShorthandAttribute
| SvelteSpreadAttribute
| SvelteDirective
| SvelteStyleDirective
| SvelteSpecialDirective
| SvelteDirectiveKey
| SvelteSpecialDirectiveKey
Expand Down Expand Up @@ -179,6 +180,7 @@ export interface SvelteStartTag extends BaseNode {
| SvelteShorthandAttribute
| SvelteSpreadAttribute
| SvelteDirective
| SvelteStyleDirective
| SvelteSpecialDirective
)[]
selfClosing: boolean
Expand Down Expand Up @@ -263,6 +265,7 @@ interface BaseSvelteMustacheTag extends BaseNode {
| SvelteAwaitCatchBlock
| SvelteKeyBlock
| SvelteAttribute
| SvelteStyleDirective
}
/** Node of mustache tag. e.g. `{...}``. Like JSXExpressionContainer */
export interface SvelteMustacheTagText extends BaseSvelteMustacheTag {
Expand Down Expand Up @@ -506,7 +509,7 @@ export interface SvelteAttribute extends BaseNode {
type: "SvelteAttribute"
key: SvelteName
boolean: boolean
value: (SvelteLiteral | (SvelteMustacheTag & { kind: "text" }))[]
value: (SvelteLiteral | SvelteMustacheTagText)[]
parent: SvelteStartTag
}
/** Node of shorthand attribute. e.g. `<img {src}>` */
Expand All @@ -529,7 +532,6 @@ export type SvelteDirective =
| SvelteAnimationDirective
| SvelteBindingDirective
| SvelteClassDirective
| SvelteStyleDirective
| SvelteEventHandlerDirective
| SvelteLetDirective
| SvelteRefDirective
Expand All @@ -538,7 +540,7 @@ export interface SvelteDirectiveKey extends BaseNode {
type: "SvelteDirectiveKey"
name: ESTree.Identifier | SvelteName
modifiers: string[]
parent: SvelteDirective
parent: SvelteDirective | SvelteStyleDirective
}

interface BaseSvelteDirective extends BaseNode {
Expand All @@ -563,10 +565,6 @@ export interface SvelteClassDirective extends BaseSvelteDirective {
kind: "Class"
expression: null | ESTree.Expression
}
export interface SvelteStyleDirective extends BaseSvelteDirective {
kind: "Style"
expression: null | ESTree.Expression | SvelteLiteral
}
export interface SvelteEventHandlerDirective extends BaseSvelteDirective {
kind: "EventHandler"
expression: null | ESTree.Expression
Expand All @@ -585,6 +583,26 @@ export interface SvelteTransitionDirective extends BaseSvelteDirective {
outro: boolean
expression: null | ESTree.Expression
}

/** Node of style directive. e.g. `<input style:color />` */
export type SvelteStyleDirective =
| SvelteStyleDirectiveShorthand
| SvelteStyleDirectiveLongform
interface BaseSvelteStyleDirective extends BaseNode {
type: "SvelteStyleDirective"
key: SvelteDirectiveKey
value: (SvelteLiteral | SvelteMustacheTagText)[]
parent: SvelteStartTag
}
export interface SvelteStyleDirectiveShorthand
extends BaseSvelteStyleDirective {
shorthand: true
value: []
}
export interface SvelteStyleDirectiveLongform extends BaseSvelteStyleDirective {
shorthand: false
value: (SvelteLiteral | SvelteMustacheTagText)[]
}
export interface SvelteSpecialDirectiveKey extends BaseNode {
type: "SvelteSpecialDirectiveKey"
parent: SvelteSpecialDirective
Expand Down
Loading