Skip to content

Commit 0e20365

Browse files
committed
Fix recursion
1 parent f716298 commit 0e20365

File tree

1 file changed

+10
-4
lines changed
  • packages/svelte/src/compiler/phases/2-analyze/visitors

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function RenderTag(node, context) {
5555
}
5656

5757
const parent = context.path.at(-2);
58-
const is_animated = snippet?.body.nodes.some(is_animate_directive);
58+
const is_animated = snippet?.body.nodes.some(n => is_animate_directive(n));
5959

6060
if(is_animated) {
6161
if (parent?.type !== 'EachBlock') {
@@ -77,11 +77,17 @@ export function RenderTag(node, context) {
7777
context.next({ ...context.state, render_tag: node });
7878
}
7979

80-
/** @param {AST.Text | AST.Tag | AST.ElementLike | AST.Comment | AST.Block} child */
81-
function is_animate_directive(child) {
80+
/**
81+
* @param {AST.Text | AST.Tag | AST.ElementLike | AST.Comment | AST.Block} child
82+
* @param {boolean} renderSnippet
83+
* @returns {boolean}
84+
*/
85+
function is_animate_directive(child, renderSnippet = false) {
8286
if (child.type === 'RenderTag') {
87+
if(renderSnippet) return false // Prevent infinite recursion
8388
for (const snippet_block of child.metadata.snippets) {
84-
return snippet_block.body.nodes.some(is_animate_directive);
89+
if(snippet_block.body.nodes.includes(child)) break
90+
return snippet_block.body.nodes.some(n => is_animate_directive(n, true));
8591
}
8692
}
8793
if (child.type !== 'RegularElement' && child.type !== 'SvelteElement') return false;

0 commit comments

Comments
 (0)