Skip to content

Commit e904753

Browse files
committed
fix
1 parent c474d67 commit e904753

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
"axobject-query": "^4.1.0",
172172
"clsx": "^2.1.1",
173173
"esm-env": "^1.2.1",
174-
"esrap": "https://pkg.pr.new/sveltejs/esrap@ef4051a",
174+
"esrap": "https://pkg.pr.new/sveltejs/esrap@17c22f5",
175175
"is-reference": "^3.0.3",
176176
"locate-character": "^3.0.0",
177177
"magic-string": "^0.30.11",

packages/svelte/scripts/process-messages/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ function run() {
147147

148148
const printed = esrap.print(
149149
ast,
150-
// @ts-expect-error
151150
ts({
152151
comments: comments.filter((comment) => comment !== jsdoc)
153152
})
@@ -358,7 +357,6 @@ function run() {
358357
.join('\n')
359358
};
360359

361-
// @ts-expect-error
362360
const block = esrap.print({ ...ast, body: [clone] }, ts({ comments: [jsdoc_clone] })).code;
363361

364362
printed.code += `\n\n${block}`;

packages/svelte/src/compiler/phases/1-parse/acorn.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ function get_comment_handlers(source, comments, index = 0) {
107107
* @param {string} value
108108
* @param {number} start
109109
* @param {number} end
110+
* @param {import('acorn').Position} [start_loc]
111+
* @param {import('acorn').Position} [end_loc]
110112
*/
111113
onComment: (block, value, start, end, start_loc, end_loc) => {
112114
if (block && /\n/.test(value)) {
@@ -125,7 +127,10 @@ function get_comment_handlers(source, comments, index = 0) {
125127
value,
126128
start,
127129
end,
128-
loc: { start: start_loc, end: end_loc }
130+
loc: {
131+
start: /** @type {import('acorn').Position} */ (start_loc),
132+
end: /** @type {import('acorn').Position} */ (end_loc)
133+
}
129134
});
130135
},
131136

packages/svelte/src/compiler/print/index.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { is_void } from '../../utils.js';
1010
export function print(ast) {
1111
// @ts-expect-error some bullshit
1212
return esrap.print(ast, {
13-
// @ts-expect-error some bullshit
1413
...ts({ comments: ast.type === 'Root' ? ast.comments : [] }),
1514
...visitors
1615
});
@@ -641,13 +640,23 @@ const visitors = {
641640
for (const modifier of node.modifiers) {
642641
context.write(`|${modifier}`);
643642
}
644-
if (
645-
node.expression !== null &&
646-
!(node.expression.type === 'Identifier' && node.expression.name === node.name)
647-
) {
648-
context.write('={');
649-
context.visit(node.expression);
650-
context.write('}');
643+
644+
if (node.value === true) {
645+
return;
646+
}
647+
648+
context.write('=');
649+
650+
if (Array.isArray(node.value)) {
651+
context.write('"');
652+
653+
for (const tag of node.value) {
654+
context.visit(tag);
655+
}
656+
657+
context.write('"');
658+
} else {
659+
context.visit(node.value);
651660
}
652661
},
653662

@@ -746,7 +755,7 @@ const visitors = {
746755
context.write('<svelte:element');
747756

748757
context.write('this={');
749-
context.visit(node.expression);
758+
context.visit(node.tag);
750759
context.write('} ');
751760

752761
for (const attribute of node.attributes) {

packages/svelte/src/compiler/types/template.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export namespace AST {
7373
/** The parsed `<script module>` element, if exists */
7474
module: Script | null;
7575
/** Comments found in <script> and {expressions} */
76-
comments: import('estree').Comment[];
76+
comments: Array<import('estree').Comment & { start: number; end: number }>;
7777
/** @internal */
7878
metadata: {
7979
/** Whether the component was parsed with typescript */

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)