Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/weak-lizards-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": patch
---

fix: infinite loop in attr.ts
10 changes: 8 additions & 2 deletions src/parser/converts/attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type {
SvelteElement,
SvelteScriptElement,
SvelteStyleElement,
SvelteElseBlock,
SvelteAwaitBlock,
} from "../../ast";
import type ESTree from "estree";
import type { Context } from "../../context";
Expand Down Expand Up @@ -678,9 +680,13 @@ function buildLetDirectiveType(

/** Find parent component element */
function findParentComponent(node: SvelteElement) {
let parent: SvelteElement["parent"] | null = node.parent;
let parent:
| SvelteElement["parent"]
| SvelteElseBlock
| SvelteAwaitBlock
| null = node.parent;
while (parent && parent.type !== "SvelteElement") {
parent = node.parent;
parent = parent.parent;
}
if (!parent || parent.kind !== "component") {
return null;
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/parser/ast/let-directive04-input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- Copied from https://github.com/sveltejs/svelte-eslint-parser/issues/408-->
<script lang="ts">
export let collapsed = false;
</script>

<div>
{#if !collapsed}
<svelte:self collapsed let:something>
<slot {something} />
</svelte:self>
{/if}
</div>
Loading