From 9b9a268cc22e7463a6401401d43ac25f0856dd19 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 12 Jul 2024 14:17:30 -0400 Subject: [PATCH] more idiomatic while loop --- packages/svelte/src/compiler/phases/2-analyze/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index b10f21b9cc..8c2a60602b 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -797,9 +797,9 @@ const legacy_scope_tweaker = { } } else if (binding?.kind === 'each' && binding.mutated) { // Ensure that the array is marked as reactive even when only its entries are mutated - let idx = -1; - let ancestor = path.at(idx); - while (ancestor) { + let i = path.length; + while (i--) { + const ancestor = path[i]; if ( ancestor.type === 'EachBlock' && state.analysis.template.scopes.get(ancestor)?.declarations.get(node.name) === binding @@ -811,7 +811,6 @@ const legacy_scope_tweaker = { } break; } - ancestor = path.at(--idx); } } }