Skip to content

Commit 859cc68

Browse files
committed
feat: support for svelte 5.0.0-next.191
1 parent 7b29182 commit 859cc68

File tree

2 files changed

+24
-33
lines changed

2 files changed

+24
-33
lines changed

package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
4848
},
4949
"peerDependencies": {
50-
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.181"
50+
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.191"
5151
},
5252
"peerDependenciesMeta": {
5353
"svelte": {
@@ -73,11 +73,11 @@
7373
"@types/eslint-visitor-keys": "^3.3.0",
7474
"@types/estree": "^1.0.5",
7575
"@types/mocha": "^10.0.7",
76-
"@types/node": "^20.14.10",
76+
"@types/node": "^20.14.11",
7777
"@types/semver": "^7.5.8",
78-
"@typescript-eslint/eslint-plugin": "^7.16.0",
79-
"@typescript-eslint/parser": "~7.16.0",
80-
"@typescript-eslint/types": "~7.16.0",
78+
"@typescript-eslint/eslint-plugin": "^7.16.1",
79+
"@typescript-eslint/parser": "~7.16.1",
80+
"@typescript-eslint/types": "~7.16.1",
8181
"benchmark": "^2.1.4",
8282
"chai": "^4.4.1",
8383
"env-cmd": "^10.1.0",
@@ -90,22 +90,22 @@
9090
"eslint-plugin-jsonc": "^2.16.0",
9191
"eslint-plugin-n": "^17.9.0",
9292
"eslint-plugin-node-dependencies": "^0.12.0",
93-
"eslint-plugin-prettier": "^5.1.3",
93+
"eslint-plugin-prettier": "^5.2.1",
9494
"eslint-plugin-regexp": "^2.6.0",
95-
"eslint-plugin-svelte": "^2.41.0",
95+
"eslint-plugin-svelte": "^2.42.0",
9696
"eslint-plugin-yml": "^1.14.0",
9797
"estree-walker": "^3.0.3",
9898
"locate-character": "^3.0.0",
9999
"magic-string": "^0.30.10",
100100
"mocha": "^10.6.0",
101101
"mocha-chai-jest-snapshot": "^1.1.4",
102102
"nyc": "^17.0.0",
103-
"prettier": "~3.3.2",
103+
"prettier": "~3.3.3",
104104
"prettier-plugin-pkg": "^0.18.1",
105-
"prettier-plugin-svelte": "^3.2.5",
106-
"rimraf": "^6.0.0",
107-
"semver": "^7.6.2",
108-
"svelte": "^5.0.0-next.181",
105+
"prettier-plugin-svelte": "^3.2.6",
106+
"rimraf": "^6.0.1",
107+
"semver": "^7.6.3",
108+
"svelte": "^5.0.0-next.191",
109109
"svelte2tsx": "^0.7.13",
110110
"typescript": "~5.5.3",
111111
"typescript-eslint-parser-for-extra-files": "^0.7.0"

src/parser/converts/attr.ts

+12-21
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,9 @@ function convertAttribute(
150150
ctx.addToken("HTMLIdentifier", keyRange);
151151
return attribute;
152152
}
153-
const value = node.value as (
154-
| Compiler.Text
155-
| Compiler.ExpressionTag
156-
| SvAST.Text
157-
| SvAST.MustacheTag
158-
| SvAST.AttributeShorthand
159-
)[];
153+
const value = Array.isArray(node.value) ? node.value : [node.value];
160154
const shorthand =
161-
value.find((v) => v.type === "AttributeShorthand") ||
155+
value.some((v) => v.type === "AttributeShorthand") ||
162156
// for Svelte v5
163157
(value.length === 1 &&
164158
value[0].type === "ExpressionTag" &&
@@ -194,12 +188,7 @@ function convertAttribute(
194188
ctx.addToken("HTMLIdentifier", keyRange);
195189

196190
processAttributeValue(
197-
node.value as (
198-
| SvAST.Text
199-
| SvAST.MustacheTag
200-
| Compiler.Text
201-
| Compiler.ExpressionTag
202-
)[],
191+
value as Exclude<(typeof value)[number], SvAST.AttributeShorthand>[],
203192
attribute,
204193
parent,
205194
ctx,
@@ -210,17 +199,19 @@ function convertAttribute(
210199

211200
/** Common process attribute value */
212201
function processAttributeValue(
213-
nodeValue: (
214-
| SvAST.Text
215-
| SvAST.MustacheTag
216-
| Compiler.Text
217-
| Compiler.ExpressionTag
218-
)[],
202+
nodeValue:
203+
| (
204+
| SvAST.Text
205+
| SvAST.MustacheTag
206+
| Compiler.Text
207+
| Compiler.ExpressionTag
208+
)[]
209+
| Compiler.ExpressionTag,
219210
attribute: SvelteAttribute | SvelteStyleDirectiveLongform,
220211
attributeParent: (SvelteAttribute | SvelteStyleDirectiveLongform)["parent"],
221212
ctx: Context,
222213
) {
223-
const nodes = nodeValue
214+
const nodes = (Array.isArray(nodeValue) ? nodeValue : [nodeValue])
224215
.filter(
225216
(v) =>
226217
v.type !== "Text" ||

0 commit comments

Comments
 (0)