Skip to content

Commit b63c305

Browse files
authored
fix: infinite loop in attr.ts (#409)
* fix: infinite loop * Create weak-lizards-listen.md * fix
1 parent f92689e commit b63c305

File tree

5 files changed

+2684
-2
lines changed

5 files changed

+2684
-2
lines changed

.changeset/weak-lizards-listen.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": patch
3+
---
4+
5+
fix: infinite loop in attr.ts

src/parser/converts/attr.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import type {
1818
SvelteElement,
1919
SvelteScriptElement,
2020
SvelteStyleElement,
21+
SvelteElseBlock,
22+
SvelteAwaitBlock,
2123
} from "../../ast";
2224
import type ESTree from "estree";
2325
import type { Context } from "../../context";
@@ -678,9 +680,13 @@ function buildLetDirectiveType(
678680

679681
/** Find parent component element */
680682
function findParentComponent(node: SvelteElement) {
681-
let parent: SvelteElement["parent"] | null = node.parent;
683+
let parent:
684+
| SvelteElement["parent"]
685+
| SvelteElseBlock
686+
| SvelteAwaitBlock
687+
| null = node.parent;
682688
while (parent && parent.type !== "SvelteElement") {
683-
parent = node.parent;
689+
parent = parent.parent;
684690
}
685691
if (!parent || parent.kind !== "component") {
686692
return null;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Copied from https://github.com/sveltejs/svelte-eslint-parser/issues/408-->
2+
<script lang="ts">
3+
export let collapsed = false;
4+
</script>
5+
6+
<div>
7+
{#if !collapsed}
8+
<svelte:self collapsed let:something>
9+
<slot {something} />
10+
</svelte:self>
11+
{/if}
12+
</div>

0 commit comments

Comments
 (0)