Skip to content

Commit 8f39241

Browse files
committed
chore: remove some todos
1 parent 9945205 commit 8f39241

File tree

24 files changed

+69
-47
lines changed

24 files changed

+69
-47
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: remove some todos

packages/svelte/src/compiler/legacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function convert(source, ast) {
190190
ClassDirective(node) {
191191
return { ...node, type: 'Class' };
192192
},
193-
Comment(node) {
193+
TemplateComment(node) {
194194
return {
195195
...node,
196196
ignores: extract_svelte_ignore(node.start, node.data, false)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ const template = {
13621362
);
13631363
}
13641364
},
1365-
Comment(node, { state }) {
1365+
TemplateComment(node, { state }) {
13661366
const migrated = migrate_svelte_ignore(node.data);
13671367
if (migrated !== node.data) {
13681368
state.str.overwrite(node.start + '<!--'.length, node.end - '-->'.length, migrated);
@@ -1707,14 +1707,14 @@ function extract_type_and_comment(declarator, state, path) {
17071707
}
17081708

17091709
// Ensure modifiers are applied in the same order as Svelte 4
1710-
const modifier_order = [
1710+
const modifier_order = /** @type {const} */ ([
17111711
'preventDefault',
17121712
'stopPropagation',
17131713
'stopImmediatePropagation',
17141714
'self',
17151715
'trusted',
17161716
'once'
1717-
];
1717+
]);
17181718

17191719
/**
17201720
* @param {AST.RegularElement | AST.SvelteElement | AST.SvelteWindow | AST.SvelteDocument | AST.SvelteBody} element

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/** @import { AST } from '#compiler' */
2-
/** @import { Comment } from 'estree' */
32
// @ts-expect-error acorn type definitions are borked in the release we use
43
import { isIdentifierStart, isIdentifierChar } from 'acorn';
54
import fragment from './state/fragment.js';

packages/svelte/src/compiler/phases/1-parse/state/element.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function element(parser) {
5959
parser.eat('-->', true);
6060

6161
parser.append({
62-
type: 'Comment',
62+
type: 'TemplateComment',
6363
start,
6464
end: parser.index,
6565
data
@@ -302,7 +302,7 @@ export default function element(parser) {
302302
if (is_top_level_script_or_style) {
303303
parser.eat('>', true);
304304

305-
/** @type {AST.Comment | null} */
305+
/** @type {AST.TemplateComment | null} */
306306
let prev_comment = null;
307307
for (let i = current.fragment.nodes.length - 1; i >= 0; i--) {
308308
const node = current.fragment.nodes[i];
@@ -311,7 +311,7 @@ export default function element(parser) {
311311
break;
312312
}
313313

314-
if (node.type === 'Comment') {
314+
if (node.type === 'TemplateComment') {
315315
prev_comment = node;
316316
break;
317317
} else if (node.type !== 'Text' || node.data.trim()) {

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ const visitors = {
8989
/** @type {string[]} */
9090
const ignores = [];
9191

92-
if (parent?.type === 'Fragment' && node.type !== 'Comment' && node.type !== 'Text') {
92+
if (parent?.type === 'Fragment' && node.type !== 'TemplateComment' && node.type !== 'Text') {
9393
const idx = parent.nodes.indexOf(/** @type {any} */ (node));
9494

9595
for (let i = idx - 1; i >= 0; i--) {
9696
const prev = parent.nodes[i];
9797

98-
if (prev.type === 'Comment') {
98+
if (prev.type === 'TemplateComment') {
9999
ignores.push(
100100
...extract_svelte_ignore(
101101
prev.start + 4 /* '<!--'.length */,

packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function SnippetBlock(node, context) {
7171
(node) =>
7272
node.type !== 'SnippetBlock' &&
7373
(node.type !== 'Text' || node.data.trim()) &&
74-
node.type !== 'Comment'
74+
node.type !== 'TemplateComment'
7575
)
7676
) {
7777
e.snippet_conflict(node);

packages/svelte/src/compiler/phases/2-analyze/visitors/Text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function Text(node, context) {
3434
for (const child of parent.nodes) {
3535
if (child === node) break;
3636

37-
if (child.type === 'Comment') {
37+
if (child.type === 'TemplateComment') {
3838
is_ignored ||= extract_svelte_ignore(
3939
child.start + 4,
4040
child.data,

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export function check_element(node, context) {
510510
}
511511
case 'figure': {
512512
const children = node.fragment.nodes.filter((node) => {
513-
if (node.type === 'Comment') return false;
513+
if (node.type === 'TemplateComment') return false;
514514
if (node.type === 'Text') return regex_not_whitespace.test(node.data);
515515
return true;
516516
});

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ export function visit_component(node, context) {
127127
context.visit(attribute, attribute.type === 'LetDirective' ? default_state : context.state);
128128
}
129129

130-
/** @type {AST.Comment[]} */
130+
/** @type {AST.TemplateComment[]} */
131131
let comments = [];
132132

133133
/** @type {Record<string, AST.Fragment['nodes']>} */
134134
const nodes = { default: [] };
135135

136136
for (const child of node.fragment.nodes) {
137-
if (child.type === 'Comment') {
137+
if (child.type === 'TemplateComment') {
138138
comments.push(child);
139139
continue;
140140
}

0 commit comments

Comments
 (0)